-
-
Notifications
You must be signed in to change notification settings - Fork 654
Fix pycodestyle warning E721 #36032
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
Fix pycodestyle warning E721 #36032
Conversation
Well, maybe I missed some of them: .pyx files in particular. I can add those on if people think this ticket is a good idea, or we can do them with a separate PR. |
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.
Thanks! We can address more such changes with another PR. |
Merge conflict |
Rebased. |
Documentation preview for this PR (built with commit 3ceb31e; changes) is ready! 🎉 |
sagemathgh-36032: Fix pycodestyle warning E721 <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> Fix the warnings coming from pycodestyle E721, "E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`". <!-- Describe your changes here in detail --> Mostly I've made changes like `type(x) == type(y)` to `type(x) is type(y)`, also adding some uses of `isinstance`. When I run `pycodestyle --select=E721 --statistics src/sage/` I now get no hits. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [X] The title is concise, informative, and self-explanatory. - [X] The description explains in detail what this PR is about. - [X] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36032 Reported by: John H. Palmieri Reviewer(s): Matthias Köppe
sagemathgh-36036: Fix E721 warnings for .pyx files Fix E721 warnings for .pyx files <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> pycodestyle reports: "E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`." So replace `type(x) == str` with `isinstance(x, str)`, replace `type(x) != type(y)` with `type(x) is not type(y)`, etc. This is a followup to sagemath#36032 which dealt with .py files. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [X] The title is concise, informative, and self-explanatory. - [X] The description explains in detail what this PR is about. - [X] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36036 Reported by: John H. Palmieri Reviewer(s): John H. Palmieri, Matthias Köppe
Fix the warnings coming from pycodestyle E721, "E721 do not compare types, for exact checks use
is
/is not
, for instance checks useisinstance()
".Mostly I've made changes like
type(x) == type(y)
totype(x) is type(y)
, also adding some uses ofisinstance
. When I runpycodestyle --select=E721 --statistics src/sage/
I now get no hits.📝 Checklist
⌛ Dependencies