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] committed Jul 22, 2024
1 parent 4725cbf commit 5b631cc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions mypy/stubdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def format_sig(
is_async: bool = False,
any_val: str | None = None,
docstring: str | None = None,
generic: str = ""
generic: str = "",
) -> str:
args: list[str] = []
for arg in self.args:
Expand Down Expand Up @@ -143,7 +143,12 @@ def format_sig(

prefix = "async " if is_async else ""
sig = "{indent}{prefix}def {name}{generic}({args}){ret}:".format(
indent=indent, prefix=prefix, name=self.name, args=", ".join(args), ret=retfield, generic=generic
indent=indent,
prefix=prefix,
name=self.name,
args=", ".join(args),
ret=retfield,
generic=generic,
)
if docstring:
suffix = f"\n{indent} {mypy.util.quote_docstring(docstring)}"
Expand Down
6 changes: 5 additions & 1 deletion mypy/stubgenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,11 @@ def generate_function_stub(
else:
generic = ""

output.extend(self.format_func_def(inferred, decorators=decorators, docstring=docstring, generic=generic))
output.extend(
self.format_func_def(
inferred, decorators=decorators, docstring=docstring, generic=generic
)
)
self._fix_iter(ctx, inferred, output)

def _indent_docstring(self, docstring: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion mypy/stubutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ def format_func_def(
indent=self._indent,
is_async=is_coroutine,
docstring=docstring if self._include_docstrings else None,
generic=generic
generic=generic,
)
)
return lines
Expand Down
3 changes: 2 additions & 1 deletion mypy/test/teststubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,15 @@ class TestClass:

def test_inline_generic_function(self) -> None:
T = TypeVar("T", bound=int)

class TestClass:
def test(self, arg0: T) -> T:
"""
test(self, arg0: T) -> T
"""
return arg0

test.__type_params__ = (T, )
test.__type_params__ = (T,)

output: list[str] = []
mod = ModuleType(TestClass.__module__, "")
Expand Down

0 comments on commit 5b631cc

Please sign in to comment.