You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unlike with runtime .py files, stub authors generally have no control over the names of variables that appear in a stub. A well-written stub should aim to faithfully represent the interface of the equivalent .py file as it exists at runtime, and that includes any ambiguously named variables in the runtime module. Even if the source code for the stubs is located in the same repository as the runtime module being stubbed, you likely won't be able to change an ambiguously named variable in the stub without also changing the corresponding runtime module, and tools like stubtest will generally help stub authors ensure consistency between the runtime module and the stub.
Would we need some kind of deprecation period for this change? Or could we just make it?
(F403 and F405 (regarding * imports) similarly flag things that are out of the control of stub authors. But these rules highlight places where ruff's inference capabilities will be severely limited due to the specific idioms being used, so I think we should probably keep these enabled by default, even for .pyi files.)
The text was updated successfully, but these errors were encountered:
I think it would make sense to have E741 (
ambiguous-variable-name
) not apply to stub files.Unlike with runtime
.py
files, stub authors generally have no control over the names of variables that appear in a stub. A well-written stub should aim to faithfully represent the interface of the equivalent.py
file as it exists at runtime, and that includes any ambiguously named variables in the runtime module. Even if the source code for the stubs is located in the same repository as the runtime module being stubbed, you likely won't be able to change an ambiguously named variable in the stub without also changing the corresponding runtime module, and tools like stubtest will generally help stub authors ensure consistency between the runtime module and the stub.Typeshed has always ignored this rule for
.pyi
files in our ruff config (and before that, in our.flake8
config), and I can't think of a situation in which it would be useful when applied to stubs.Would we need some kind of deprecation period for this change? Or could we just make it?
(F403 and F405 (regarding
*
imports) similarly flag things that are out of the control of stub authors. But these rules highlight places where ruff's inference capabilities will be severely limited due to the specific idioms being used, so I think we should probably keep these enabled by default, even for.pyi
files.)The text was updated successfully, but these errors were encountered: