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

Update to mypy 0.971 #11640

Merged
merged 10 commits into from
Sep 9, 2022
Merged

Conversation

wence-
Copy link
Contributor

@wence- wence- commented Sep 1, 2022

Description

Update to current mypy, primarily since on Apple silicon, the previous pinned version of mypy is no longer installable (typed-ast does not build from source). This necessitates some minor updates to the type annotation rules, since the newer mypy version is a bit pickier.

While we're here, exclude directories we were previously just ignoring errors in.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@wence- wence- requested a review from a team as a code owner September 1, 2022 16:17
@github-actions github-actions bot added the Python Affects Python cuDF API. label Sep 1, 2022
@wence- wence- added 3 - Ready for Review Ready for review by team code quality non-breaking Non-breaking change and removed Python Affects Python cuDF API. labels Sep 1, 2022
@vyasr vyasr added the improvement Improvement / enhancement to an existing function label Sep 1, 2022
.pre-commit-config.yaml Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

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

We'll also want to update the conda environment:

I expect this may cause compatibility issues and require a broader update of mypy across RAPIDS. Alternatively, we can remove mypy from the conda environment (so it can't conflict with other RAPIDS envs) and solely rely on pre-commit for managing the version and executing the check.

Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

This is a surprisingly minimal changeset. I thought the update required more changes than this, but perhaps that was due to unrelated incompatibilities? If CI passes then that's good enough for me.

@vyasr
Copy link
Contributor

vyasr commented Sep 1, 2022

We'll also want to update the conda environment:

I expect this may cause compatibility issues and require a broader update of mypy across RAPIDS. Alternatively, we can remove mypy from the conda environment (so it can't conflict with other RAPIDS envs) and solely rely on pre-commit for managing the version and executing the check.

I believe cudf is the only package in RAPIDS that uses mypy at all, so it shouldn't cause any problems (unless there are incompatibilities with dependencies).

@github-actions github-actions bot added the Python Affects Python cuDF API. label Sep 1, 2022
Avoids need to explicit-package-bases
setup.cfg Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
@github-actions github-actions bot added the conda label Sep 2, 2022
@bdice
Copy link
Contributor

bdice commented Sep 2, 2022

@wence- Before merging, can you please write a PR description describing the motivation for this change and the scope of the changes? (Ideally we would use the PR template checklist, too.)

conda/environments/cudf_dev_cuda11.5.yml Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
setup.cfg Show resolved Hide resolved
@wence-
Copy link
Contributor Author

wence- commented Sep 5, 2022

@wence- Before merging, can you please write a PR description describing the motivation for this change and the scope of the changes? (Ideally we would use the PR template checklist, too.)

Done.

Co-authored-by: Bradley Dice <[email protected]>
@wence-
Copy link
Contributor Author

wence- commented Sep 5, 2022

Final question to address is what we want to do about missing imports in the pre-commit environment.

Copy link
Member

@ajschmidt8 ajschmidt8 left a comment

Choose a reason for hiding this comment

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

This will also need to be updated in the integration repository below. Can you update the mypy version and add the types-cachetools package to the rapids-build-env package?

@bdice
Copy link
Contributor

bdice commented Sep 7, 2022

@ajschmidt8 @wence- @vyasr Longer term, as the integration repo is phased out, we may not want to keep “developer tools” like mypy, flake8, black in the conda environment if they are being managed by pre-commit for a given repo. Users wanting consistency with CI style checks must run mypy through pre-commit and not as a standalone executable from the conda environment. There’s not much reason to keep mypy in the conda environment unless it helps developers’ IDE settings, but the results will not necessarily be consistent with what pre-commit’s mypy expects. The pre-commit environment is ultimately our source of truth for CI and local pre-commit checks.

@ajschmidt8
Copy link
Member

@bdice, so pre-commit is also used in CI? If that's the case, then I'm fine with either of the following:

  1. Removing mypy from our integration repository entirely
  2. Updating it to match the version in this PR

Based on your comment, it seems like it never really needed to be in the integration repository packages in the first place, right?

@bdice
Copy link
Contributor

bdice commented Sep 7, 2022

@ajschmidt8 We used the integration repo's copy of mypy until #9412. That changed cudf over to using the pre-commit executable (and its managed versions of various linters/formatters) instead of the versions of black, flake8, mypy, etc. from the user's environment (which is the integration environment on CI).

pre-commit run --hook-stage manual --all-files

To my knowledge, the only reason we should keep those tools in the cuDF environment is for developers who want IDE integration (usually for VS Code) with black or clang-format, which is harder to achieve when calling via pre-commit because it doesn't have the expected executable in the PATH.

If no developers want it installed in the development environment for purposes of IDE integration, it would be safe to remove from the cuDF conda environment file. Same for other "developer" tools like flake8, black, pydocstyle. I'd think this is unrelated / unaffected by the integration repo so that pinning could probably be deleted entirely if cuDF is the only RAPIDS package that needs it.

@ajschmidt8
Copy link
Member

@bdice, got it. we can remove those packages from integration if you'd like. But we have to be prepared to deal with any unexpected fallout if we do. Seems like the easiest path here would be to just continue to keep the versions in-sync until we truly deprecate that repository. But if you're prepared to address any potential fallout, then feel free to open a PR to remove them 🙂.

@bdice
Copy link
Contributor

bdice commented Sep 7, 2022

Seems like the easiest path here would be to just continue to keep the versions in-sync until we truly deprecate that repository.

I'm 100% in favor of that path. Just wanted to clarify that the integration mypy is not used by cuDF CI, so that we can revisit and simplify in the future.

@vyasr
Copy link
Contributor

vyasr commented Sep 7, 2022

I'm fine with the path outlined above. I agree that we can remove linters from the environment in the long run and just relyin on pre-commit, and I'm also happy to let this happen organically as integration is phased out rather than trying to be proactive in simplifying a repo that is going away anyway.

Also, to answer the question about who uses which linters, AFAIK cudf is the only RAPIDS library using mypy and pydocstyle. I think that it is also the only library using black, but there's been enough interest from other libraries that even if nobody has implemented it yet it's likely that other libraries will start using it eventually.

Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

Apologies for the delay in re-reviewing this. Looks mostly fine, there are a couple of minor questions I have left then we should be good to go.

.pre-commit-config.yaml Show resolved Hide resolved
conda/environments/cudf_dev_cuda11.5.yml Show resolved Hide resolved
python/cudf/cudf/core/dataframe.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/indexed_frame.py Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
setup.cfg Show resolved Hide resolved
wence- added a commit to wence-/rapids-integration that referenced this pull request Sep 8, 2022
@wence-
Copy link
Contributor Author

wence- commented Sep 8, 2022

This will also need to be updated in the integration repository below. Can you update the mypy version and add the types-cachetools package to the rapids-build-env package?

Done here: rapidsai/integration#531

@vyasr vyasr requested a review from ajschmidt8 September 9, 2022 16:59
ajschmidt8 added a commit to rapidsai/integration that referenced this pull request Sep 9, 2022
Update mypy version in build env in line with rapidsai/cudf#11640
@vyasr
Copy link
Contributor

vyasr commented Sep 9, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit f485667 into rapidsai:branch-22.10 Sep 9, 2022
@wence- wence- deleted the wence/mypy-update branch September 9, 2022 17:03
rapids-bot bot pushed a commit that referenced this pull request Sep 12, 2022
As part of #11640, there was a missing exclusion for `cudf/cudf/utils/metadata/orc_column_statistics_pb2.py`, that causes the following errors:
```bash
(cudfdev) pgali@dt07:/nvme/0/pgali/cudf$ git commit -m "address reviews"
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/nfs/pgali/.cache/pre-commit/patch1662993629-63423.
isort....................................................................Passed
black....................................................................Passed
flake8...................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:7: error: Library stubs not installed for "google.protobuf.internal" (or incompatible with Python 3.9)
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:7: note: Hint: "python3 -m pip install types-protobuf"
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:7: note: (or run "mypy --install-types" to install all missing stub packages)
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:7: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:8: error: Library stubs not installed for "google.protobuf" (or incompatible with Python 3.9)
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:25: error: Name "_BUCKETSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:26: error: Name "_BUCKETSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:27: error: Name "_INTEGERSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:28: error: Name "_INTEGERSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:29: error: Name "_DOUBLESTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:30: error: Name "_DOUBLESTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:31: error: Name "_STRINGSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:32: error: Name "_STRINGSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:33: error: Name "_BUCKETSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:34: error: Name "_BUCKETSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:35: error: Name "_DECIMALSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:36: error: Name "_DECIMALSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:37: error: Name "_DATESTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:38: error: Name "_DATESTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:39: error: Name "_TIMESTAMPSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:40: error: Name "_TIMESTAMPSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:41: error: Name "_BINARYSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:42: error: Name "_BINARYSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:43: error: Name "_COLUMNSTATISTICS" is not defined
python/cudf/cudf/utils/metadata/orc_column_statistics_pb2.py:44: error: Name "_COLUMNSTATISTICS" is not defined
Found 22 errors in 1 file (checked 138 source files)

pydocstyle...............................................................Passed
clang-format.........................................(no files to check)Skipped
no-deprecationwarning....................................................Passed
cmake-format.........................................(no files to check)Skipped
- hook id: cmake-format
cmake-lint...........................................(no files to check)Skipped
- hook id: cmake-lint
copyright-check..........................................................Passed
doxygen-check........................................(no files to check)Skipped
- hook id: doxygen-check
[INFO] Restored changes from /home/nfs/pgali/.cache/pre-commit/patch1662993629-63423.
```

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)

URL: #11685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants