Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and ericmarkmartin committed Jun 29, 2024
1 parent bce35a3 commit 1842993
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions mypy/stubgenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,11 @@ def get_annotation(key: str) -> str | None:
arglist: list[ArgSig] = []

# Add the arguments to the signature
def add_args(args, get_default_value: Callable[[int, str], object | None]):
def add_args(args: list[str], get_default_value: Callable[[int, str], object | None]) -> None:
for i, arg in enumerate(args):
# Check if the argument has a default value
if default_value := get_default_value(i, arg):
default_value = get_default_value(i, arg)
if default_value is not None:
if arg in annotations:
argtype = annotations[arg]
else:
Expand All @@ -325,7 +326,7 @@ def add_args(args, get_default_value: Callable[[int, str], object | None]):
else:
arglist.append(ArgSig(arg, get_annotation(arg), default=False))

def get_pos_default(i: int, _arg: str) -> object | None:
def get_pos_default(i: int, _arg: str) -> Any | None:
if defaults and i >= len(args) - len(defaults):
return defaults[i - (len(args) - len(defaults))]
else:
Expand All @@ -340,7 +341,7 @@ def get_pos_default(i: int, _arg: str) -> object | None:
elif kwonlyargs:
arglist.append(ArgSig("*"))

def get_kw_default(_i: int, arg: str) -> object | None:
def get_kw_default(_i: int, arg: str) -> Any | None:
if kwonlydefaults:
return kwonlydefaults.get(arg)
else:
Expand Down
5 changes: 2 additions & 3 deletions mypy/test/teststubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,9 @@ class TestClassVariableCls:
assert_equal(gen.get_imports().splitlines(), ["from typing import ClassVar"])
assert_equal(output, ["class C:", " x: ClassVar[int] = ..."])


def test_non_c_generate_signature_with_kw_only_args(self) -> None:
class TestClass:
def test(self, arg0, *, keyword_only : str, keyword_only_with_default : int = 7):
def test(self, arg0: str, *, keyword_only: str, keyword_only_with_default: int = 7) -> None:
pass

output: list[str] = []
Expand All @@ -869,7 +868,7 @@ def test(self, arg0, *, keyword_only : str, keyword_only_with_default : int = 7)
assert_equal(
output,
[
"def test(self, arg0, *, keyword_only: str, keyword_only_with_default: int = ...): ..."
"def test(self, arg0: str, *, keyword_only: str, keyword_only_with_default: int = ...): ..."
],
)

Expand Down

0 comments on commit 1842993

Please sign in to comment.