@@ -272,15 +272,17 @@ class PydanticMixin:
272272
273273 if TYPE_CHECKING :
274274 pydantic_enabled : bool
275- pydantic_validate_arguments_import_name : str | None
276275
277276 def visit (self , node : ast .AST ) -> ast .AST : # noqa: D102
278277 ...
279278
279+ def lookup_full_name (self , node : ast .AST ) -> str | None : # noqa: D102
280+ ...
281+
280282 def _function_is_wrapped_by_validate_arguments (self , node : FunctionDef | AsyncFunctionDef ) -> bool :
281283 if self .pydantic_enabled and node .decorator_list :
282284 for decorator_node in node .decorator_list :
283- if getattr (decorator_node , 'id' , '' ) == self . pydantic_validate_arguments_import_name :
285+ if self . lookup_full_name (decorator_node ) == 'pydantic.validate_arguments' :
284286 return True
285287 return False
286288
@@ -1043,7 +1045,6 @@ def __init__(
10431045 )
10441046 self .injector_enabled = injector_enabled
10451047 self .pydantic_enabled_baseclass_passlist = pydantic_enabled_baseclass_passlist
1046- self .pydantic_validate_arguments_import_name = None
10471048 self .cwd = cwd # we need to know the current directory to guess at which imports are remote and which are not
10481049
10491050 #: A list of modules that re-export symbols from the typing module
@@ -1365,14 +1366,6 @@ def add_import(self, node: Import) -> None: # noqa: C901
13651366 # Skip checking the import if the module is passlisted
13661367 exempt = all_exempt or (isinstance (node , ast .Import ) and self .is_exempt_module (name_node .name ))
13671368
1368- # Look for pydantic.validate_arguments import
1369- # TODO: Switch to using lookup_full_name instead
1370- if name_node .name == 'validate_arguments' :
1371- if name_node .asname is not None :
1372- self .pydantic_validate_arguments_import_name = name_node .asname
1373- else :
1374- self .pydantic_validate_arguments_import_name = name_node .name
1375-
13761369 if name_node .name == '*' :
13771370 # don't record * imports
13781371 continue
0 commit comments