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

Mutable dataclass field checks don't respect immutable annotations #4038

Closed
charliermarsh opened this issue Apr 20, 2023 · 3 comments · Fixed by #4039
Closed

Mutable dataclass field checks don't respect immutable annotations #4038

charliermarsh opened this issue Apr 20, 2023 · 3 comments · Fixed by #4039
Labels
bug Something isn't working

Comments

@charliermarsh
Copy link
Member

charliermarsh commented Apr 20, 2023

Originally posted by @andersk in #3877 (comment)

@charliermarsh charliermarsh added the bug Something isn't working label Apr 20, 2023
@dhruvmanila
Copy link
Member

I can take this up :)

Am I correct to assume that the said helper function in the original comment should be refactored to ruff_python_semantic? This is because it's dependent on Context.

@Pentusha
Copy link

I think my case is suitable for this issue:

error message:

 edgeql_qb/render/types.py:10:27: RUF009 Do not perform function call `FrozenDict` in dataclass defaults

immutable dataclass with immutable field:

@dataclass(slots=True, frozen=True)
class RenderedQuery:
    query: str = ''
    context: FrozenDict = FrozenDict()

Hashable (Immutable) FrozenDict code here.
For me it seems like false positive.

Ref: Pentusha/edgeql-qb#92

@dhruvmanila
Copy link
Member

@Pentusha This comes from RUF009 while this issue is to track RUF008. Yours is a valid case as well but it might be difficult to detect due to the lack of type inference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants