Repository navigation
23.1.1
New error codes:
- Y052: Disallow default values in global or class namespaces where the assignment does not have a type annotation. Stubs should be explicit about the type of all variables in the stub; without type annotations, the type checker is forced to make inferences, which may have unpredictable consequences. Enum members are excluded from this check, as are various special assignments such as
__all__and__match_args__.
Other changes:
- Disallow numeric default values where
len(str(default)) > 7. If a function has a default value where the string representation is greater than 7 characters, it is likely to be an implementation detail or a constant that varies depending on the system you're running on, such assys.maxsize. - Disallow
strorbytesdefaults where the default is >50 characters long, for similar reasons. - Allow
ast.Attributenodes as default values for a small number of special cases, such assys.maxsizeandsys.executable. - Fewer Y020 false positives are now emitted when encountering default values in stub files.