-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
B039 considers frozenset
to be mutable
#14525
Comments
Also appears to be the case for |
Conversely, the error is silenced if the context var is an annotated mutable type:
|
To recap: from contextvars import ContextVar
# All of these should produce an error but foo3 and foo4 don't.
foo1 = ContextVar('foo1', default=set())
foo2 = ContextVar('foo2', default=set[object]())
foo3 = ContextVar[set[object]]('foo3', default=set())
foo4 = ContextVar[set[object]]('foo4', default=set[object]())
foo5: ContextVar[set[object]] = ContextVar('foo5', default=set())
foo6: ContextVar[set[object]] = ContextVar('foo6', default=set[object]())
# None of these should produce an error but bar2 and bar6 do.
bar1 = ContextVar('bar1', default=frozenset())
bar2 = ContextVar('bar2', default=frozenset[object]())
bar3 = ContextVar[frozenset[object]]('bar3', default=frozenset())
bar4 = ContextVar[frozenset[object]]('bar4', default=frozenset[object]())
bar5: ContextVar[frozenset[object]] = ContextVar('bar5', default=frozenset())
bar6: ContextVar[frozenset[object]] = ContextVar('bar6', default=frozenset[object]()) |
@AlexWaygood can I work on this? |
@harupy sure! |
@harupy this function will probably be helpful in fixing some of the issues here: ruff/crates/ruff_python_ast/src/helpers.rs Lines 660 to 670 in b80de52
|
@AlexWaygood Thanks! |
Filed #14532 |
The text was updated successfully, but these errors were encountered: