summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2022-04-21 23:06:31 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2022-04-22 00:12:47 +0200
commit8bab34e23c88057753bc251373467c47a6c66ba7 (patch)
tree466effe8cb17e3a922c9bb0d2236f2a04a9b7596
parentc9c75177bcdbe4f9c59d7a95a57d13a623a85b47 (diff)
downloadpylint-git-8bab34e23c88057753bc251373467c47a6c66ba7.tar.gz
[typing] Add missing type in the private import checker
-rw-r--r--pylint/checkers/utils.py2
-rw-r--r--pylint/extensions/private_import.py8
2 files changed, 6 insertions, 4 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 38100e135..383550415 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -701,7 +701,7 @@ def get_argument_from_call(
raise NoSuchArgumentError
-def inherit_from_std_ex(node: nodes.NodeNG) -> bool:
+def inherit_from_std_ex(node: nodes.NodeNG | astroid.Instance) -> bool:
"""Return whether the given class node is subclass of
exceptions.Exception.
"""
diff --git a/pylint/extensions/private_import.py b/pylint/extensions/private_import.py
index 75d305ed4..3fb36f27b 100644
--- a/pylint/extensions/private_import.py
+++ b/pylint/extensions/private_import.py
@@ -112,7 +112,7 @@ class PrivateImportChecker(BaseChecker):
)
def _get_type_annotation_names(
- self, node: nodes.Import, names: list[str]
+ self, node: nodes.Import | nodes.ImportFrom, names: list[str]
) -> list[str]:
"""Removes from names any names that are used as type annotations with no other illegal usages."""
if names and not self.populated_annotations:
@@ -185,7 +185,7 @@ class PrivateImportChecker(BaseChecker):
def _populate_type_annotations_annotation(
self,
- node: nodes.Attribute | nodes.Subscript | nodes.Name,
+ node: nodes.Attribute | nodes.Subscript | nodes.Name | None,
all_used_type_annotations: dict[str, bool],
) -> str | None:
"""Handles the possiblity of an annotation either being a Name, i.e. just type,
@@ -240,7 +240,9 @@ class PrivateImportChecker(BaseChecker):
return True
@staticmethod
- def same_root_dir(node: nodes.Import, import_mod_name: str) -> bool:
+ def same_root_dir(
+ node: nodes.Import | nodes.ImportFrom, import_mod_name: str
+ ) -> bool:
"""Does the node's file's path contain the base name of `import_mod_name`?"""
if not import_mod_name: # from . import ...
return True