@@ -883,6 +883,9 @@ class TypeChecker(BaseChecker):
883
883
),
884
884
)
885
885
886
+ def __init__ (self , linter : "PyLinter" ) -> None :
887
+ super ().__init__ (linter , future_option_parsing = True )
888
+
886
889
def open (self ) -> None :
887
890
py_version = get_global_option (self , "py-version" )
888
891
self ._py310_plus = py_version >= (3 , 10 )
@@ -899,7 +902,7 @@ def _compiled_generated_members(self) -> Tuple[Pattern, ...]:
899
902
# (surrounded by quote `"` and followed by a comma `,`)
900
903
# REQUEST,aq_parent,"[a-zA-Z]+_set{1,2}"' =>
901
904
# ('REQUEST', 'aq_parent', '[a-zA-Z]+_set{1,2}')
902
- generated_members = self .config .generated_members
905
+ generated_members = self .linter . namespace .generated_members
903
906
if isinstance (generated_members , str ):
904
907
gen = shlex .shlex (generated_members )
905
908
gen .whitespace += ","
@@ -986,7 +989,7 @@ def visit_attribute(self, node: nodes.Attribute) -> None:
986
989
]
987
990
if (
988
991
len (non_opaque_inference_results ) != len (inferred )
989
- and self .config .ignore_on_opaque_inference
992
+ and self .linter . namespace .ignore_on_opaque_inference
990
993
):
991
994
# There is an ambiguity in the inference. Since we can't
992
995
# make sure that we won't emit a false positive, we just stop
@@ -995,7 +998,10 @@ def visit_attribute(self, node: nodes.Attribute) -> None:
995
998
for owner in non_opaque_inference_results :
996
999
name = getattr (owner , "name" , None )
997
1000
if _is_owner_ignored (
998
- owner , name , self .config .ignored_classes , self .config .ignored_modules
1001
+ owner ,
1002
+ name ,
1003
+ self .linter .namespace .ignored_classes ,
1004
+ self .linter .namespace .ignored_modules ,
999
1005
):
1000
1006
continue
1001
1007
@@ -1024,8 +1030,8 @@ def visit_attribute(self, node: nodes.Attribute) -> None:
1024
1030
owner ,
1025
1031
name ,
1026
1032
self ._mixin_class_rgx ,
1027
- ignored_mixins = self .config .ignore_mixin_members ,
1028
- ignored_none = self .config .ignore_none ,
1033
+ ignored_mixins = self .linter . namespace .ignore_mixin_members ,
1034
+ ignored_none = self .linter . namespace .ignore_none ,
1029
1035
):
1030
1036
continue
1031
1037
missingattr .add ((owner , name ))
@@ -1080,12 +1086,12 @@ def _get_nomember_msgid_hint(self, node, owner):
1080
1086
hint = ""
1081
1087
else :
1082
1088
msg = "no-member"
1083
- if self .config .missing_member_hint :
1089
+ if self .linter . namespace .missing_member_hint :
1084
1090
hint = _missing_member_hint (
1085
1091
owner ,
1086
1092
node .attrname ,
1087
- self .config .missing_member_hint_distance ,
1088
- self .config .missing_member_max_choices ,
1093
+ self .linter . namespace .missing_member_hint_distance ,
1094
+ self .linter . namespace .missing_member_max_choices ,
1089
1095
)
1090
1096
else :
1091
1097
hint = ""
@@ -1335,7 +1341,7 @@ def visit_call(self, node: nodes.Call) -> None:
1335
1341
1336
1342
# Has the function signature changed in ways we cannot reliably detect?
1337
1343
if hasattr (called , "decorators" ) and decorated_with (
1338
- called , self .config .signature_mutators
1344
+ called , self .linter . namespace .signature_mutators
1339
1345
):
1340
1346
return
1341
1347
@@ -1709,7 +1715,7 @@ def visit_with(self, node: nodes.With) -> None:
1709
1715
# Check if we are dealing with a function decorated
1710
1716
# with contextlib.contextmanager.
1711
1717
if decorated_with (
1712
- inferred .parent , self .config .contextmanager_decorators
1718
+ inferred .parent , self .linter . namespace .contextmanager_decorators
1713
1719
):
1714
1720
continue
1715
1721
# If the parent of the generator is not the context manager itself,
@@ -1737,7 +1743,9 @@ def visit_with(self, node: nodes.With) -> None:
1737
1743
scope = inferred_path .scope ()
1738
1744
if not isinstance (scope , nodes .FunctionDef ):
1739
1745
continue
1740
- if decorated_with (scope , self .config .contextmanager_decorators ):
1746
+ if decorated_with (
1747
+ scope , self .linter .namespace .contextmanager_decorators
1748
+ ):
1741
1749
break
1742
1750
else :
1743
1751
self .add_message (
@@ -1754,7 +1762,7 @@ def visit_with(self, node: nodes.With) -> None:
1754
1762
if not has_known_bases (inferred ):
1755
1763
continue
1756
1764
# Just ignore mixin classes.
1757
- if self .config .ignore_mixin_members :
1765
+ if self .linter . namespace .ignore_mixin_members :
1758
1766
if inferred .name [- 5 :].lower () == "mixin" :
1759
1767
continue
1760
1768
@@ -1999,6 +2007,9 @@ class IterableChecker(BaseChecker):
1999
2007
),
2000
2008
}
2001
2009
2010
+ def __init__ (self , linter : "PyLinter" ) -> None :
2011
+ super ().__init__ (linter , future_option_parsing = True )
2012
+
2002
2013
@staticmethod
2003
2014
def _is_asyncio_coroutine (node ):
2004
2015
if not isinstance (node , nodes .Call ):
0 commit comments