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

Use mypy for static type checking #1275

Merged
merged 2 commits into from Jan 2, 2021
Merged

Use mypy for static type checking #1275

merged 2 commits into from Jan 2, 2021

Conversation

jdufresne
Copy link
Member

@jdufresne jdufresne commented Dec 15, 2020

Type checking helps give confidence that APIs are being used correctly,
especially during large refactoring (e.g. eventually dropping Python 2
support).

This initial pass only includes type comments that were necessary to
make mypy pass. Future pull requests will add types for the rest of the
project once the workflow is established.

pip has started including type annotation in a subset of its code. When
major changes to pip are released, the type checking will help identify
API mismatches and areas to adjust.

mypy is configured to be as strict as possible without introducing
errors. The configuration is a subset of the --strict CLI argument.

Refs #972

Contributor checklist
  • Provided the tests for the changes.
  • Gave a clear one-line description in the PR (that the maintainers can add to CHANGELOG.md on release).
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

@jdufresne jdufresne added the ci Related to continuous integration tasks label Dec 15, 2020
@jdufresne jdufresne added this to the 5.5.0 milestone Dec 15, 2020
@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #1275 (6ed320e) into master (fb5486b) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1275   +/-   ##
=======================================
  Coverage   99.65%   99.65%           
=======================================
  Files          35       35           
  Lines        2897     2898    +1     
  Branches      322      322           
=======================================
+ Hits         2887     2888    +1     
  Misses          5        5           
  Partials        5        5           
Impacted Files Coverage Δ
piptools/logging.py 100.00% <100.00%> (ø)
piptools/scripts/compile.py 100.00% <100.00%> (ø)
piptools/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb5486b...6ed320e. Read the comment docs.

@jdufresne
Copy link
Member Author

The failure is being addressed in typeshed here: python/typeshed#4825

@atugushev
Copy link
Member

atugushev commented Dec 16, 2020

See also #972 and #971

@atugushev atugushev modified the milestones: 5.5.0, 6.0.0 Dec 30, 2020
@jdufresne
Copy link
Member Author

The failure would also be addressed by dropping Python 2 support, see #1243. If that lands, I'll rebase this work.

@jdufresne
Copy link
Member Author

Changes:

  • Rebased
  • Changed type comments to type annotations
  • Dropped import guard; the typing module is available on all support Pythons

tox.ini Outdated Show resolved Hide resolved
.github/workflows/qa.yml Outdated Show resolved Hide resolved
Type checking helps give confidence that APIs are being used correctly,
especially during large refactoring (e.g. eventually dropping Python 2
support).

This initial pass only includes type annotations that were necessary to
make mypy pass. Future pull requests will add types for the rest of the
project once the workflow is established.

pip has started including type annotation in a subset of its code. When
major changes to pip are released, the type checking will help identify
API mismatches and areas to adjust.

mypy is configured to be as strict as possible without introducing
errors. The configuration is a subset of the --strict CLI argument.

Refs #972
@jdufresne
Copy link
Member Author

No problem. Moved to pre-commit.

Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

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

👍

@jdufresne jdufresne merged commit cc2d08f into jazzband:master Jan 2, 2021
@jdufresne jdufresne deleted the mypy-master branch January 2, 2021 16:07
@atugushev atugushev mentioned this pull request Feb 4, 2021
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Related to continuous integration tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants