Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[red-knot] Attribute assignments in @staticmethods should not influence instance attributes #15961

Open
Tracked by #14164
sharkdp opened this issue Feb 5, 2025 · 0 comments
Labels
bug Something isn't working red-knot Multi-file analysis & type inference

Comments

@sharkdp
Copy link
Contributor

sharkdp commented Feb 5, 2025

The goal of this issue is to get rid of the TODO comments in this test. An attribute assignment in a @staticmethod should not influence the existence of implicit (instance) attributes:

class Unrelated:
    x: int

class C:
    @staticmethod
    def f(unrelated: Unrelated):
        unrelated.x = 1

reveal_type(C().x)  # should be an error

Whether or not this requires special-casing of @staticmethod during semantic index building is an open question. The answer to this question influences whether or not we can also handle the more exotic edge-cases in the mentioned test (e.g. aliased @staticmethod).

Part of: #14164

@sharkdp sharkdp changed the title Make sure that attribute assignments in @staticmethods are not considered to be instance attributes [red-knot] Attribute assignments in @staticmethods should not influence instance attributes Feb 5, 2025
@sharkdp sharkdp added red-knot Multi-file analysis & type inference bug Something isn't working labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working red-knot Multi-file analysis & type inference
Projects
None yet
Development

No branches or pull requests

1 participant