Skip to content

Upgrade flake8 to 6.0.0 #7222

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

Closed
wants to merge 9 commits into from
Closed

Conversation

mpearce25
Copy link
Contributor

Addresses: #7200

Changes

  • Upgrade flake8 version
  • Match flake8 versions between CI and contributing guide
  • Move flake8 install cmd to clearer location in contributing guide

Typing updates

For torchvision/models/detection/generalized_rcnn.py type hints were:

Testing

  • flake8
  • mypy

@facebook-github-bot
Copy link

Hi @mpearce25!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@mpearce25 mpearce25 marked this pull request as draft February 11, 2023 00:45
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@pmeier pmeier self-requested a review February 13, 2023 11:06
@pmeier
Copy link
Collaborator

pmeier commented Feb 13, 2023

Hey @mpearce25 and thanks for the PR. We are currently on a very tight schedule for some stuff that we need to finish until end of week for the next release. I'll come back to this next week. In case I forget, feel free to ping me.

@justinchuby
Copy link
Contributor

Have we considered using lintrunner and ruff in this project?

@johnnynunez
Copy link

Hey @mpearce25 and thanks for the PR. We are currently on a very tight schedule for some stuff that we need to finish until end of week for the next release. I'll come back to this next week. In case I forget, feel free to ping me.

why not to move to ruff? https://github.com/charliermarsh/ruff

@pmeier
Copy link
Collaborator

pmeier commented Feb 20, 2023

Have we considered using lintrunner and ruff in this project?

Yes, but it is not a priority right now. There is a push from Nova to unite the CI system across all domain libraries, but linting is at the bottom of their list.

why not to move to ruff? https://github.com/charliermarsh/ruff

Because that costs time that we currently don't have. ruff labels itself as alpha product in contrast to flake8, which is stable since forever. I personally use ruff for my own small projects, but for projects as large as PyTorch there is a lot more to consider.

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks @mpearce25 for the PR! I have a small comment inline. Otherwise LGTM if CI is green.

CONTRIBUTING.md Outdated
@@ -83,7 +83,7 @@ Instead of relying directly on `black` however, we rely on
[ufmt](https://github.com/omnilib/ufmt), for compatibility reasons with Facebook
internal infrastructure.

To format your code, install `ufmt` with `pip install ufmt==1.3.2 black==22.3.0 usort==1.0.2` and use e.g.:
To format your code, install `ufmt` with `pip install ufmt==1.3.2 black==22.3.0 usort==1.0.2 flake8=6.0.0` and use e.g.:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this section is about formatting, can we not include flake8 here, but rather have a separate installation command below where flake8 usage is explained? Alternatively, we could also rephrase this to not start with

To format your code, install ufmt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I split up the formatting and linting sections.

Also promoted the "typing" section to same level as formatting/linting and unit tests. Mypy operates independently from fromatting/linting and I wanted to avoid confusion in the pre-commit hooks section.

lmk if these changes look good.

CI is failing same as other PRs. Issues seem unrelated, but I'm fine waiting until everything is green again to avoid compounding any CI issues.

Copy link
Collaborator

Choose a reason for hiding this comment

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

CI is failing same as other PRs. Issues seem unrelated, but I'm fine waiting until everything is green again to avoid compounding any CI issues.

Just as a heads up, this will take some time. See #7299.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous issue that led to these type hints being removed is partially hidden behind internal meta tools, but seems to basically be https://github.com/pytorch/vision/pull/4631/files#r744161323 .

Imo it would be odd to sacrifice typing in torchvision just to avoid adding some type ignore or assert in the 3rd party code. However, lmk if that's not the case.

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Two nits inline. Otherwise LGTM!

@mpearce25 mpearce25 marked this pull request as ready for review February 24, 2023 02:28
@pmeier pmeier self-requested a review February 24, 2023 08:50
@pmeier pmeier mentioned this pull request Jun 19, 2023
@mpearce25 mpearce25 closed this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants