Skip to content

[flake8-bugbear] Fix mutable-contextvar-default (B039) to resolve annotated function calls properly#14532

Merged
charliermarsh merged 5 commits intoastral-sh:mainfrom
harupy:issue-14525
Nov 24, 2024
Merged

[flake8-bugbear] Fix mutable-contextvar-default (B039) to resolve annotated function calls properly#14532
charliermarsh merged 5 commits intoastral-sh:mainfrom
harupy:issue-14525

Conversation

@harupy
Copy link
Contributor

@harupy harupy commented Nov 22, 2024

Summary

Fix #14525

Test Plan

New test cases

@harupy harupy changed the title [flake8-bugbear] Fix mutable-contextvar-default (B039) to handle annotated calls [flake8-bugbear] Fix mutable-contextvar-default (B039) to handle annotated calls properly Nov 22, 2024
@harupy harupy changed the title [flake8-bugbear] Fix mutable-contextvar-default (B039) to handle annotated calls properly [flake8-bugbear] Fix mutable-contextvar-default (B039) to flag annotated function calls Nov 22, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@harupy harupy changed the title [flake8-bugbear] Fix mutable-contextvar-default (B039) to flag annotated function calls [flake8-bugbear] Fix mutable-contextvar-default (B039) to resolve annotated function calls properly Nov 22, 2024
@MichaReiser MichaReiser added the bug Something isn't working label Nov 22, 2024
&& checker
.semantic()
.resolve_qualified_name(&call.func)
.resolve_qualified_name(map_subscript(&call.func))
Copy link
Contributor Author

@harupy harupy Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but shoud we check if call.func is contextvars.Contextvar first (and exit if not) before checking if arguments has a keyword default to avoid unnecessary work (immutability check and extending the immutable expressions)?

@charliermarsh charliermarsh merged commit e3d7926 into astral-sh:main Nov 24, 2024
@charliermarsh
Copy link
Member

Thanks!

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 this pull request may close these issues.

B039 considers frozenset to be mutable

3 participants