diff --git a/docs/source/stubgen.rst b/docs/source/stubgen.rst index c8965d7e20f85..26ac8d5a4aa21 100644 --- a/docs/source/stubgen.rst +++ b/docs/source/stubgen.rst @@ -139,8 +139,8 @@ alter the default behavior: Import and inspect modules instead of parsing source code. This is the default behavior for c modules and pyc-only packages. The flag is useful to force - inspection for pure python modules that make use of dynamically generated - members that would otherwiswe be omitted when using the default behavior of + inspection for pure python modules that make use of dynamically generated + members that would otherwiswe be omitted when using the default behavior of code parsing. Implies :option:`--no-analysis` as analysis requires source code. diff --git a/mypy/stubgen.py b/mypy/stubgen.py index 2e646e841b276..b6d6ace0a00ca 100755 --- a/mypy/stubgen.py +++ b/mypy/stubgen.py @@ -42,14 +42,12 @@ from __future__ import annotations import argparse -import glob import keyword import os import os.path import sys import traceback -from collections import defaultdict -from typing import Final, Iterable, Mapping +from typing import Final, Iterable from typing_extensions import Final import mypy.build @@ -113,10 +111,10 @@ from mypy.stubdoc import ArgSig, FunctionSig from mypy.stubgenc import InspectionStubGenerator, generate_stub_for_c_module from mypy.stubutil import ( + BaseStubGenerator, CantImport, ClassInfo, FunctionContext, - BaseStubGenerator, common_dir_prefix, fail_missing, find_module_path_and_all_py3, diff --git a/mypy/stubgenc.py b/mypy/stubgenc.py index ace0abdf90a2d..da3cfc6f6e914 100755 --- a/mypy/stubgenc.py +++ b/mypy/stubgenc.py @@ -11,10 +11,8 @@ import inspect import keyword import os.path -import re -from abc import abstractmethod from types import FunctionType, ModuleType -from typing import Any, Final, Mapping +from typing import Any, Mapping from mypy.fastparse import parse_type_comment from mypy.moduleinspect import is_c_module @@ -31,10 +29,10 @@ parse_all_signatures, ) from mypy.stubutil import ( + BaseStubGenerator, ClassInfo, FunctionContext, SignatureGenerator, - BaseStubGenerator, infer_method_ret_type, ) @@ -587,7 +585,7 @@ def _fix_iter( ctx.class_info and ctx.class_info.cls is not None and ctx.name == "__getitem__" - and "__iter__" not in getattr(ctx.class_info.cls, "__dict__") + and "__iter__" not in ctx.class_info.cls.__dict__ ): item_type: str | None = None for sig in inferred: diff --git a/mypy/stubutil.py b/mypy/stubutil.py index dfb04976badb1..2ff50b9bcef68 100644 --- a/mypy/stubutil.py +++ b/mypy/stubutil.py @@ -2,7 +2,6 @@ from __future__ import annotations -import keyword import os.path import re import sys diff --git a/test-data/unit/stubgen.test b/test-data/unit/stubgen.test index 5264d70b5f642..7e265e231a263 100644 --- a/test-data/unit/stubgen.test +++ b/test-data/unit/stubgen.test @@ -2853,7 +2853,7 @@ __uri__ = '' __version__ = '' [out] -from m import __version__ as __version__ +from m import __version__ as __version__ class A: ...