@@ -308,6 +308,9 @@ def _is_object(node: ast.AST | None, name: str, *, from_: Container[str]) -> boo
308308_is_BaseException = partial (_is_object , name = "BaseException" , from_ = {"builtins" })
309309_is_TypeAlias = partial (_is_object , name = "TypeAlias" , from_ = _TYPING_MODULES )
310310_is_NamedTuple = partial (_is_object , name = "NamedTuple" , from_ = _TYPING_MODULES )
311+ _is_deprecated = partial (
312+ _is_object , name = "deprecated" , from_ = {"typing_extensions" , "warnings" }
313+ )
311314_is_TypedDict = partial (
312315 _is_object , name = "TypedDict" , from_ = _TYPING_MODULES | {"mypy_extensions" }
313316)
@@ -958,6 +961,7 @@ class PyiVisitor(ast.NodeVisitor):
958961 all_name_occurrences : Counter [str ]
959962
960963 string_literals_allowed : NestingCounter
964+ long_strings_allowed : NestingCounter
961965 in_function : NestingCounter
962966 in_class : NestingCounter
963967 visiting_arg : NestingCounter
@@ -975,6 +979,7 @@ def __init__(self, filename: str) -> None:
975979 self .typealias_decls = defaultdict (list )
976980 self .all_name_occurrences = Counter ()
977981 self .string_literals_allowed = NestingCounter ()
982+ self .long_strings_allowed = NestingCounter ()
978983 self .in_function = NestingCounter ()
979984 self .in_class = NestingCounter ()
980985 self .visiting_arg = NestingCounter ()
@@ -1156,6 +1161,11 @@ def visit_Call(self, node: ast.Call) -> None:
11561161 if _is_bad_TypedDict (node ):
11571162 self .error (node , Y031 )
11581163 return
1164+ elif _is_deprecated (function ):
1165+ with self .string_literals_allowed .enabled (), self .long_strings_allowed .enabled ():
1166+ for arg in chain (node .args , node .keywords ):
1167+ self .visit (arg )
1168+ return
11591169 elif (
11601170 isinstance (function , ast .Attribute )
11611171 and isinstance (function .value , ast .Name )
@@ -1176,7 +1186,10 @@ def visit_Call(self, node: ast.Call) -> None:
11761186 def visit_Constant (self , node : ast .Constant ) -> None :
11771187 if isinstance (node .value , str ) and not self .string_literals_allowed .active :
11781188 self .error (node , Y020 )
1179- elif isinstance (node .value , (str , bytes )):
1189+ elif (
1190+ isinstance (node .value , (str , bytes ))
1191+ and not self .long_strings_allowed .active
1192+ ):
11801193 if len (node .value ) > 50 :
11811194 self .error (node , Y053 )
11821195 elif isinstance (node .value , (int , float , complex )):
0 commit comments