diff --git a/doc/whatsnew/fragments/8387.feature b/doc/whatsnew/fragments/8387.feature new file mode 100644 index 0000000000..2b4df0001f --- /dev/null +++ b/doc/whatsnew/fragments/8387.feature @@ -0,0 +1,3 @@ +pylint now supports ``TryStar`` nodes from Python 3.11 and should be fully compatible with Python 3.11. + +Closes #8387 diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index 7270ea3689..ba526821a9 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -891,7 +891,7 @@ def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None: if context_name == importedmodname: self.add_message("import-self", node=node) - elif not astroid.modutils.is_standard_module(importedmodname): + elif not astroid.modutils.is_stdlib_module(importedmodname): # if this is not a package __init__ module if base != "__init__" and context_name not in self._module_pkg: # record the module's parent, or the module itself if this is diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 8448a0f13b..e401134735 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -790,7 +790,7 @@ def _infer_from_metaclass_constructor( def _is_c_extension(module_node: InferenceResult) -> bool: return ( isinstance(module_node, nodes.Module) - and not astroid.modutils.is_standard_module(module_node.name) + and not astroid.modutils.is_stdlib_module(module_node.name) and not module_node.fully_defined() ) diff --git a/pylint/pyreverse/inspector.py b/pylint/pyreverse/inspector.py index 9150bbef3c..cf22d7eb15 100644 --- a/pylint/pyreverse/inspector.py +++ b/pylint/pyreverse/inspector.py @@ -300,14 +300,14 @@ def visit_importfrom(self, node: nodes.ImportFrom) -> None: if fullname != basename: self._imported_module(node, fullname, relative) - def compute_module(self, context_name: str, mod_path: str) -> int: - """Return true if the module should be added to dependencies.""" + def compute_module(self, context_name: str, mod_path: str) -> bool: + """Should the module be added to dependencies ?""" package_dir = os.path.dirname(self.project.path) if context_name == mod_path: - return 0 - if astroid.modutils.is_standard_module(mod_path, (package_dir,)): - return 1 - return 0 + return False + # astroid does return a boolean but is not typed correctly yet + + return astroid.modutils.module_in_path(mod_path, (package_dir,)) # type: ignore[no-any-return] def _imported_module( self, node: nodes.Import | nodes.ImportFrom, mod_path: str, relative: bool diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py index 88e3d05356..3d0a4613ab 100644 --- a/pylint/pyreverse/writer.py +++ b/pylint/pyreverse/writer.py @@ -136,7 +136,7 @@ def get_class_properties(self, obj: ClassEntity) -> NodeProperties: def get_shape_color(self, obj: DiagramEntity) -> str: """Get shape color.""" qualified_name = obj.node.qname() - if modutils.is_standard_module(qualified_name.split(".", maxsplit=1)[0]): + if modutils.is_stdlib_module(qualified_name.split(".", maxsplit=1)[0]): return "grey" if isinstance(obj.node, nodes.ClassDef): package = qualified_name.rsplit(".", maxsplit=2)[0] diff --git a/pyproject.toml b/pyproject.toml index 1c8a915acc..333d2856ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ dependencies = [ # Also upgrade requirements_test_min.txt. # Pinned to dev of second minor update to allow editable installs and fix primer issues, # see https://github.com/PyCQA/astroid/issues/1341 - "astroid>=2.14.2,<=2.16.0-dev0", + "astroid>=2.15.0,<=2.17.0-dev0", "isort>=4.2.5,<6", "mccabe>=0.6,<0.8", "tomli>=1.1.0;python_version<'3.11'", diff --git a/requirements_test_min.txt b/requirements_test_min.txt index 7328b2bf81..d3a76f096c 100644 --- a/requirements_test_min.txt +++ b/requirements_test_min.txt @@ -1,6 +1,6 @@ -e .[testutils,spelling] # astroid dependency is also defined in pyproject.toml -astroid==2.14.2 # Pinned to a specific version for tests +astroid==2.15.0 # Pinned to a specific version for tests typing-extensions~=4.5 py~=1.11.0 pytest~=7.2