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

DEV: Move Ruff rule PLW3301 #3093

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

DEV: Move Ruff rule PLW3301 #3093

wants to merge 2 commits into from

Conversation

j-t-1
Copy link
Contributor

@j-t-1 j-t-1 commented Jan 29, 2025

Move from tool.ruff.lint (global) to tool.ruff.lint.per-file-ignores. PLW3301: nested-min-max. Nested min and max calls can be flattened into a single call to improve readability.

j-t-1 added 2 commits January 29, 2025 10:50
Move from tool.ruff.lint (global) to tool.ruff.lint.per-file-ignores. PLW3301: nested-min-max. Nested min and max calls can be flattened into a single call to improve readability.
Move from tool.ruff.lint (global) to tool.ruff.lint.per-file-ignores. PLW3301: nested-min-max. Nested min and max calls can be flattened into a single call to improve readability.
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.50%. Comparing base (8b3a786) to head (09df735).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3093   +/-   ##
=======================================
  Coverage   96.50%   96.50%           
=======================================
  Files          52       52           
  Lines        8806     8806           
  Branches     1612     1612           
=======================================
  Hits         8498     8498           
  Misses        183      183           
  Partials      125      125           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@j-t-1
Copy link
Contributor Author

j-t-1 commented Jan 29, 2025

out = min(out, min([x for x in loc.values() if p < x <= p1]))

I tried and failed to make the min call flattened into a single call:

out = min(out, *[int(x) for x in loc.values() if p < x <= p1])

FAILED tests/test_reader.py::test_iss2082 - TypeError: 'int' object is not iterable
FAILED tests/test_writer.py::test_issue301 - TypeError: 'int' object is not iterable
FAILED tests/test_writer.py::test_append_pages_from_reader_append - TypeError: 'int' object is not iterable

@stefan6419846
Copy link
Collaborator

You cannot pass an empty list - this is (one of the reasons) why the AttributeError is caught:

>>> min([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: min() arg is an empty sequence
>>> min(5, *[])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable

@stefan6419846
Copy link
Collaborator

Are you planning to fix the violations in this PR as well, or is this ready to be merged?

@j-t-1
Copy link
Contributor Author

j-t-1 commented Jan 30, 2025

Ready to be merged.

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.

2 participants