Skip to content

Commit

Permalink
remove from typing import Any, Tuple from generated friendly modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd committed Jul 14, 2024
1 parent 5b72b7a commit ec0b9b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion comtypes/tools/codegenerator/codegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def generate_wrapper_code(
print("from typing import TYPE_CHECKING", file=output)
print(file=output)
print("if TYPE_CHECKING:", file=output)
print(" from typing import Any, Tuple", file=output)
print(" from comtypes import hints", file=output)
print(file=output)
print(file=output)
Expand Down
10 changes: 5 additions & 5 deletions comtypes/tools/codegenerator/typeannotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ def getvalue(self, name: str) -> str:
has_optional = False
for _, argname, default in self.inarg_specs:
if keyword.iskeyword(argname):
inargs = ["*args: Any", "**kwargs: Any"]
inargs = ["*args: hints.Any", "**kwargs: hints.Any"]
break
if default is None:
if has_optional:
# probably propput or propputref
# HACK: Something that goes into this conditional branch
# should be a special callback.
inargs.append("**kwargs: Any")
inargs.append("**kwargs: hints.Any")
break
inargs.append(f"{argname}: hints.Incomplete")
else:
Expand All @@ -251,7 +251,7 @@ def getvalue(self, name: str) -> str:
elif len(outargs) == 1:
out = outargs[0]
else:
out = "Tuple[" + ", ".join(outargs) + "]"
out = "hints.Tuple[" + ", ".join(outargs) + "]"
in_ = ("self, " + ", ".join(inargs)) if inargs else "self"
return f"def {name}({in_}) -> {out}: ..."

Expand All @@ -275,14 +275,14 @@ def getvalue(self, name: str) -> str:
has_optional = False
for _, argname, default in self.inarg_specs:
if keyword.iskeyword(argname):
inargs = ["*args: Any", "**kwargs: Any"]
inargs = ["*args: hints.Any", "**kwargs: hints.Any"]
break
if default is None:
if has_optional:
# probably propput or propputref
# HACK: Something that goes into this conditional branch
# should be a special callback.
inargs.append("**kwargs: Any")
inargs.append("**kwargs: hints.Any")
break
inargs.append(f"{argname}: hints.Incomplete")
else:
Expand Down

0 comments on commit ec0b9b9

Please sign in to comment.