-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2504 Apply one time pyupgrade --py37-plus v3.3.2 and ruff #1196
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
Conversation
I'm waiting until we get mypy working to mark this as ready. |
2d653ed
to
f85b2f9
Compare
43c7074
to
6f4af5a
Compare
The |
I'm going to back out the mypy changes for this PR and open a new ticket. |
I reopened https://jira.mongodb.org/browse/PYTHON-3679 to track mypy --strict support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I'm going to wait until #1138 is merged to avoid adding merge conflicts to that PR. |
…test/*.py tools/*.py test/*/*.py
Rebased and reran the upgrade commands. Waiting for tests to pass. |
bson/__init__.py
Outdated
@@ -269,10 +267,12 @@ def _get_string( | |||
length = _UNPACK_INT_FROM(data, position)[0] | |||
position += 4 | |||
if length < 1 or obj_end - position < length: | |||
raise InvalidBSON("invalid string length") | |||
msg = "invalid string length" | |||
raise InvalidBSON(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ew I don't like what ruff is doing here at all. Looking for a code to disable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That rule comes from https://pypi.org/project/flake8-errmsg/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caused by https://beta.ruff.rs/docs/rules/#flake8-errmsg-em
Disabling now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I do actually agree that the exception traceback is clearer with the temp variable but I just don't like it from a code readability standpoint.
…ne-length=100 --unfixable COM812,D400,D415,ERA001,RUF100,SIM108,D211,D212,SIM105,SIM,PT,ANN204,EM bson/*.py pymongo/*.py gridfs/*.py test/*.py test/*/*.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some spot checks, LGTM!
https://jira.mongodb.org/browse/PYTHON-2504
Successor to #882.
Ran this repeatedly until it stablized after 3 or 4 runs:
I also ran ruff 0.0.265 like this (see https://beta.ruff.rs/docs/rules/):
The --unfixable codes suppress some unneeded or particularly noisy changes.
As noted in the previous PR:
I'll add this to
.git-blame-ignore-revs
after the PR is merged.