diff --git a/astroid/brain/brain_mechanize.py b/astroid/brain/brain_mechanize.py index 0f0d0193b..62cc2d05c 100644 --- a/astroid/brain/brain_mechanize.py +++ b/astroid/brain/brain_mechanize.py @@ -2,12 +2,13 @@ # For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE # Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt +from astroid import nodes from astroid.brain.helpers import register_module_extender from astroid.builder import AstroidBuilder from astroid.manager import AstroidManager -def mechanize_transform(): +def mechanize_transform() -> nodes.Module: return AstroidBuilder(AstroidManager()).string_build( """class Browser(object): def __getattr__(self, name): diff --git a/astroid/context.py b/astroid/context.py index 0b8c259fc..d5efc9a27 100644 --- a/astroid/context.py +++ b/astroid/context.py @@ -15,7 +15,8 @@ if TYPE_CHECKING: from astroid import constraint, nodes - from astroid.nodes.node_classes import Keyword, NodeNG + from astroid.nodes.node_classes import Keyword + from astroid.nodes.node_ng import NodeNG _InferenceCache = dict[ tuple["NodeNG", Optional[str], Optional[str], Optional[str]], Sequence["NodeNG"] diff --git a/astroid/modutils.py b/astroid/modutils.py index 957be61cb..29d09f860 100644 --- a/astroid/modutils.py +++ b/astroid/modutils.py @@ -272,7 +272,7 @@ def _get_relative_base_path(filename: str, path_to_check: str) -> list[str] | No def modpath_from_file_with_callback( filename: str, - path: Sequence[str] | None = None, + path: list[str] | None = None, is_package_cb: Callable[[str, list[str]], bool] | None = None, ) -> list[str]: filename = os.path.expanduser(_path_from_filename(filename)) @@ -298,7 +298,7 @@ def modpath_from_file_with_callback( ) -def modpath_from_file(filename: str, path: Sequence[str] | None = None) -> list[str]: +def modpath_from_file(filename: str, path: list[str] | None = None) -> list[str]: """Get the corresponding split module's name from a filename. This function will return the name of a module or package split on `.`. @@ -607,7 +607,7 @@ def is_relative(modname: str, from_file: str) -> bool: @lru_cache(maxsize=1024) -def cached_os_path_isfile(path: str | os.PathLike) -> bool: +def cached_os_path_isfile(path: str | os.PathLike[str]) -> bool: """A cached version of os.path.isfile that helps avoid repetitive I/O""" return os.path.isfile(path) diff --git a/pyproject.toml b/pyproject.toml index 165d74301..c7e55d10d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,7 @@ files = [ "astroid/brain/brain_hashlib.py", "astroid/brain/brain_http.py", "astroid/brain/brain_hypothesis.py", + "astroid/brain/brain_mechanize.py", "astroid/brain/brain_numpy_core_einsumfunc.py", "astroid/brain/brain_numpy_core_fromnumeric.py", "astroid/brain/brain_numpy_core_function_base.py", @@ -95,7 +96,9 @@ files = [ "astroid/brain/brain_unittest.py", "astroid/brain/brain_uuid.py", "astroid/const.py", + "astroid/context.py", "astroid/interpreter/_import/", + "astroid/modutils.py", "astroid/nodes/const.py", "astroid/nodes/utils.py", ]