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

Enable ruff flake8-builtins rule #2930

Merged
merged 9 commits into from
Jan 25, 2024

Conversation

CoolCat467
Copy link
Member

This pull request enables ruff's flake8-builtins rule, sorts the enabled rules and ignored rules sections, and fixes or ignores a lot of newly generated "argument or variable is shadowing a python builtin" errors.

Copy link

codecov bot commented Jan 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0204d04) 99.64% compared to head (67116bc) 99.64%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2930   +/-   ##
=======================================
  Coverage   99.64%   99.64%           
=======================================
  Files         116      116           
  Lines       17503    17503           
  Branches     3148     3148           
=======================================
  Hits        17441    17441           
  Misses         43       43           
  Partials       19       19           
Files Coverage Δ
src/trio/_core/_io_kqueue.py 87.20% <100.00%> (ø)
src/trio/_core/_tests/test_asyncgen.py 100.00% <100.00%> (ø)
src/trio/_highlevel_open_tcp_listeners.py 100.00% <100.00%> (ø)
src/trio/_socket.py 100.00% <100.00%> (ø)
src/trio/_subprocess.py 100.00% <100.00%> (ø)
...c/trio/_tests/test_highlevel_open_tcp_listeners.py 100.00% <100.00%> (ø)
src/trio/_tests/test_highlevel_open_tcp_stream.py 100.00% <100.00%> (ø)
src/trio/_tests/test_socket.py 100.00% <100.00%> (ø)
src/trio/testing/_fake_net.py 100.00% <100.00%> (ø)

@Fuyukai
Copy link
Member

Fuyukai commented Jan 22, 2024

Why is this three separate PRs that will all conflict due to all three reformattting the pyproject.toml?

@CoolCat467
Copy link
Member Author

Because they are separate rules, and if they conflict I will deal with that.

@CoolCat467
Copy link
Member Author

The segfault in pypy-3.9 happened again: https://github.com/python-trio/trio/actions/runs/7607032357/job/20713702030#step:5:1186
For future reference, where should these be recorded?

@A5rocks
Copy link
Contributor

A5rocks commented Jan 22, 2024

Gah, well see the segfaults don't exactly provide much information... But I agree that it's annoying. At this point ig we might as well make an issue here (on trio) to track things cause upstream pytest hasn't been able to solve this yet.


Also, I don't really see the use of this rule. We have type checkers; I don't see the issue with this shadowing. Maybe others see issue though?

@CoolCat467
Copy link
Member Author

In all reality we might not need flake8-builtins, but I wanted to throw it out there because it's a part of best practice not to shadow builtins.

@jakkdl
Copy link
Member

jakkdl commented Jan 24, 2024

I'm in favor of not shadowing builtins in general, type checking might catch most errors it might lead to (only if the object is different though!) - but I can definitely see it causing confusion/lead to bugs/etc.

Copy link
Member

@jakkdl jakkdl left a comment

Choose a reason for hiding this comment

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

actually, after reading through all the diffs I think we should ignore A002 - but we could keep A001. We're never going to change the argument names for external-facing functions, and I'm not sure it's worth the need for lots of ugly noqas to be extra safe on internal functions.

Copy link
Member

@jakkdl jakkdl left a comment

Choose a reason for hiding this comment

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

Looks great!

@CoolCat467 CoolCat467 merged commit 05c5df2 into python-trio:master Jan 25, 2024
29 checks passed
@CoolCat467 CoolCat467 deleted the enable-flake8-builtins branch January 25, 2024 21:58
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.

5 participants