Skip to content
Merged

Up #141

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 93 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exclude = '''
| buck-out
| build
| dist
| typings
)/
'''

Expand Down Expand Up @@ -70,6 +71,7 @@ exclude = [
".tox",
".venv",
".vscode",
"typings",
"__pypackages__",
"_build",
"buck-out",
Expand Down Expand Up @@ -109,6 +111,8 @@ ignore = [
"N802",
"UP007",
"UP045",
"UP031",
"F841",
]
select = [
"E", # pycodestyle (error)
Expand Down Expand Up @@ -149,7 +153,6 @@ warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false
ignore_missing_imports = true
line-length = 120

[tool.pylint.messages_control]
max-line-length = 120
Expand All @@ -158,3 +161,92 @@ disable = [
"C0103", # invalid-name
"R0913", # too-many-arguments
]


[tool.pyright]
# Target Python version for type analysis
pythonVersion = "3.13"
stubPath = "typings"
# Paths to include and exclude from checking
include = ["src"]
exclude = ["typings", "**/node_modules", "**/__pycache__", ".venv"]

# Diagnostic modes: "basic" or "standard" or "strict"
typeCheckingMode = "basic"

# Automatically find virtual environments
venvPath = "."
venv = ".venv"

# Fine-tune specific warning rules
reportMissingTypeStubs = false
reportGeneralTypeIssues = false
reportUnknownMemberType = false
enableReachabilityAnalysis = false
strictListInference = false
strictDictionaryInference = false
strictSetInference = false
deprecateTypingAliases = false
enableExperimentalFeatures = false

analyzeUnannotatedFunctions = true
disableBytesTypePromotions = true
strictParameterNoneValue = true
enableTypeIgnoreComments = true
reportMissingModuleSource = "warning"
reportInvalidTypeForm = "warning"
reportMissingImports = "warning"
reportUndefinedVariable = "warning"

reportReturnType = false
reportArgumentType = false
reportAttributeAccessIssue = "warning"
reportAssignmentType = "warning"
reportOptionalMemberAccess = "warning"
reportCallIssue = "warning"
reportOptionalSubscript = "warning"


# -----
reportAbstractUsage = false
reportAssertAlwaysTrue = false
reportAssertTypeFailure = false
reportCallInDefaultInitializer = false
reportConstantRedefinition = false
reportDeprecated = false
reportDuplicateImport = false
reportFunctionMemberAccess = false
reportImplicitOverride = false
reportImplicitStringConcatenation = false
reportImportCycles = false
reportIncompatibleMethodOverride = false
reportIncompatibleVariableOverride = false
reportIncompleteStub = false
reportInconsistentOverload = false
reportIndexIssue = false
reportInvalidStringEscapeSequence = false
reportInvalidStubStatement = false
reportInvalidTypeArguments = false
reportInvalidTypeVarUse = false
reportMatchNotExhaustive = false
reportMissingParameterType = false
reportMissingSuperCall = false
reportMissingTypeArgument = false
reportOperatorIssue = false
reportOptionalCall = false
reportOptionalContextManager = false
reportOptionalIterable = false
reportOptionalOperand = false
reportOverlappingOverload = false
reportPossiblyUnboundVariable = false
reportPrivateImportUsage = false
reportPrivateUsage = false
reportPropertyTypeMismatch = false
reportRedeclaration = false
reportTypeCommentUsage = false
reportTypedDictNotRequiredAccess = false
reportUnboundVariable = false
reportUnhashable = false
reportUninitializedInstanceVariable = false
reportUnknownArgumentType = false
reportUnknownLambdaType = false
6 changes: 3 additions & 3 deletions src/WDYe/ali.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
}


def action_one(q, ar):
def action_one(q, ar) -> None:
logger.info(f"<<lightblue>>> {q}:{ar} ")
ar2 = ar
if ar.find("عبد ") != -1:
Expand All @@ -161,7 +161,7 @@ def action_one(q, ar):
WD_API_Bot.Alias_API(q, [ar2], "ar", False)


def workqua(qua):
def workqua(qua) -> None:
# ---
qua = qua + Limit[1]
logger.info(qua)
Expand All @@ -174,7 +174,7 @@ def workqua(qua):
action_one(pa["item"], pa["label"])


def mains():
def mains() -> None:
logger.info("start with query")
# ---
FFF = True
Expand Down
8 changes: 4 additions & 4 deletions src/WDYe/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
qid_table[labe] = qid


def WORK(item, table, type):
def WORK(item, table, type) -> None:
# logger.info( item )
logger.info(table)
# logger.info( '<<lightgreen>> item:"%s" ' % item )
# ---
arlab = table["label"][0]
arlab2 = arlab
alias = table["alias"]
# alias = table["alias"]
if type in allise:
logger.info(f'<<lightgreen>> type:"{type}" in allise:"{allise[type]}" ')
arlab2 = re.sub(f"^{type} ", f"{allise[type]} ", arlab2)
Expand Down Expand Up @@ -85,7 +85,7 @@ def WORK(item, table, type):
LIMIT """


def WORK_table(qid, tables):
def WORK_table(qid, tables) -> None:
# qid = qid_table.get( peo , "" )
for peo in tables:
qua = Quaa % (qid, peo)
Expand All @@ -111,7 +111,7 @@ def WORK_table(qid, tables):
WORK(item, value, peo)


def main():
def main() -> None:
# python pwb.py wd/med mainkey subcats
# python pwb.py wd/med short subcats
# python pwb.py wd/med subcats ta:horror
Expand Down
2 changes: 1 addition & 1 deletion src/WDYe/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Limit = {1: "500"}


def main():
def main() -> None:
# python pwb.py wd/category
# ---
for arg in sys.argv:
Expand Down
10 changes: 6 additions & 4 deletions src/WDYe/catwithoutp31.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
}


def Get_Sitelinks_From_wikidata(site, title, ssite="", ids="", props="", add_props=None, return_main_table=False):
def Get_Sitelinks_From_wikidata(
site, title, ssite: str = "", ids: str = "", props: str = "", add_props=None, return_main_table: bool = False
):
# ---
sitewiki = site
if site.find("wiki") == -1:
Expand All @@ -68,7 +70,7 @@ def Get_Sitelinks_From_wikidata(site, title, ssite="", ids="", props="", add_pro
if props:
params["props"] = props
# ---
if isinstance(add_props, (list, tuple)):
if isinstance(add_props, list | tuple):
for x in add_props:
if x not in params["props"]:
params["props"] += f"|{x}"
Expand Down Expand Up @@ -98,7 +100,7 @@ def Get_Sitelinks_From_wikidata(site, title, ssite="", ids="", props="", add_pro
return table


def work_one_item(q):
def work_one_item(q) -> None:
# ---
# claims
P31 = wd_bot.Get_Property_API(q=q, p="P31")
Expand Down Expand Up @@ -149,7 +151,7 @@ def work_one_item(q):
logger.info(f"<<lightred>>* work 2 :{q} no descriptions to add.")


def main():
def main() -> None:
# ---
for qua_a in quaries:
qua = quaries[qua_a]
Expand Down
6 changes: 3 additions & 3 deletions src/WDYe/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@
limiTa = ["Wikimedia category", "Wikimedia disambiguation page"]


def main():
def main() -> None:
logger.info("*<<lightyellow>> main:")
queries_list = sorted(list(queries.keys()))
queries_list = sorted(queries.keys())
lenth = len(queries_list)
for numb, topic in enumerate(queries_list, start=1):
if topic in DescraptionsTable:
Expand All @@ -141,7 +141,7 @@ def main():
logger.info("Finished successfully")


def Main_Test():
def Main_Test() -> None:
wikidatasite = pywikibot.Site("wikidata", "wikidata")
repo = wikidatasite.data_repository()
# ---
Expand Down
4 changes: 2 additions & 2 deletions src/WDYe/d1.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}


def work2(q, topic):
def work2(q, topic) -> None:
# ---
ItemDescriptions = wd_bot.Get_item_descriptions_or_labels(q, "descriptions")
# ---
Expand Down Expand Up @@ -103,7 +103,7 @@ def work2(q, topic):
wd_desc.wwdesc(NewDesc, q, 1, fixlang, ask=False)


def mam():
def mam() -> None:
topic = "species of insect"
logger.info("*<<lightyellow>> mainfromQuarry:")
Quarry = quuu[topic]
Expand Down
11 changes: 3 additions & 8 deletions src/WDYe/disam2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}


def work2(q, topic):
def work2(q, topic) -> None:
# ---
# logger.info( '<<lightyellow>> **newdesc: work2:' + q)
# ItemDescriptions = {}
Expand Down Expand Up @@ -64,13 +64,8 @@ def work2(q, topic):
work_api_desc(NewDesc, q)


def mainfromQuarry():
def mainfromQuarry() -> None:
logger.info("*<<lightyellow>> mainfromQuarry:")
Quarry = """SELECT DISTINCT ?item
WHERE {
?item schema:description "یک صفحهٔ ابهام\\u200cزدایی در ویکی\\u200cپدیا"@fa.
}
limit 10000"""

Quarry2 = """SELECT ?item
WHERE {VALUES (?item) {(wd:Q29976539) }
Expand All @@ -89,7 +84,7 @@ def mainfromQuarry():
repo = wikidatasite.data_repository()


def mainfromQuarry2():
def mainfromQuarry2() -> None:
logger.info("*<<lightyellow>> mainfromQuarry:")
# ---
# quarrr = '207388'
Expand Down
6 changes: 3 additions & 3 deletions src/WDYe/indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
missing_dict = {}


def fixlabel(oldlabel):
def fixlabel(oldlabel: str):
new = oldlabel.replace("٠", "0").replace("١", "1").replace("٢", "2").replace("٣", "3").replace("٤", "4")
return new.replace("٥", "5").replace("٦", "6").replace("٧", "7").replace("٨", "8").replace("٩", "9")


def one_item(wditem):
def one_item(wditem) -> int:
global items2do
items2do -= 1
if wditem.labels: # تسميات موجودة
Expand All @@ -35,7 +35,7 @@ def wd_sparql_generator(query):
yield wd


def main():
def main() -> None:
global itemsdone
itemsdone = 0
max = 10
Expand Down
12 changes: 6 additions & 6 deletions src/WDYe/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
missing_dict = {}


def preee(wditem, data, site):
def preee(wditem, data, site) -> None:
wditem.editEntity(data, summary=f"Bot: Add Arabic label: {site}")


def one_q_item(wditem):
def one_q_item(wditem) -> int:
global items2do
items2do -= 1
if "arwiki" in wditem.sitelinks:
Expand All @@ -55,13 +55,13 @@ def one_q_item(wditem):
return 1


def action_item2(wditem):
def action_item2(wditem) -> int:
global items2do
items2do -= 1
if "arwiki" in wditem.sitelinks:
ma = wditem.sitelinks["arwiki"]
wditem.sitelinks["arwiki"]
if "ar" in wditem.sitelinks:
ma = wditem.sitelinks["arwiki"]
wditem.sitelinks["arwiki"]
# print(ma)
# site = ma.title
# if site:
Expand Down Expand Up @@ -113,7 +113,7 @@ def wd_sparql_generator(query):
yield wd


def main():
def main() -> None:
global itemsdone
itemsdone = 0
print("- بدء المهمة")
Expand Down
4 changes: 2 additions & 2 deletions src/WDYe/labelnumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
missing_dict = {}


def onee_item(wditem):
def onee_item(wditem) -> int:
global items2do
items2do -= 1
if wditem.labels: # تسميات موجودة
Expand All @@ -29,7 +29,7 @@ def wd_sparql_generator(query):
yield wd


def main():
def main() -> None:
global itemsdone
itemsdone = 0
max = 10
Expand Down
Loading