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

Ruff does not understand contextlib.suppress #216

Merged
merged 1 commit into from
Jul 13, 2024

Conversation

masklinn
Copy link
Contributor

Not entirely clear when F811 started triggering on this pattern (it didn't 3 months ago but is now unhappy with this).

Use find_spec to perform a conditional import rather than recover from a failing import. This is generally less efficient, but given it's only done at import it likely doesnt matter.

  • successfully importing a module takes about 65ns
  • successfully find_spec-ing a module takes about 280ns
  • unsuccessfully find_spec-ing a module takes about 21µs
  • unsuccessfully importing a modules (then recovering) takes about 26µs

@masklinn masklinn enabled auto-merge (rebase) July 13, 2024 13:19
Not entirely clear when F811 started triggering on this pattern (it
didn't 3 months ago but is now unhappy with this).

Use `find_spec` to perform a conditional import rather than recover
from a failing import. This is generally less efficient, but given
it's only done at import it likely doesnt matter.

- successfully importing a module takes about 65ns
- successfully find_spec-ing a module takes about 280ns
- unsuccessfully find_spec-ing a module takes about 21*µ*s
- unsuccessfully importing a modules (then recovering) takes about 26µs
@masklinn masklinn merged commit db3385d into ua-parser:master Jul 13, 2024
29 checks passed
@masklinn masklinn deleted the fix-ruff-error branch July 13, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant