WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@atugushev
Copy link
Member

@atugushev atugushev commented Jul 20, 2023

Since 21.1 pip has py.typed file, hence many updates on type annotations.

Contributor checklist
  • Provided the tests for the changes.
  • Assure PR title is short, clear, and good to be included in the user-oriented changelog
Maintainer checklist
  • Assure one of these labels is present: backwards incompatible, feature, enhancement, deprecation, bug, dependency, docs or skip-changelog as they determine changelog listing.
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

@atugushev
Copy link
Member Author

atugushev commented Jul 20, 2023

@AndydeCleyre

FYI, this is pre-step towards addressing the following comments:

@atugushev atugushev added the skip-changelog Avoid listing in changelog label Jul 20, 2023
@atugushev atugushev marked this pull request as ready for review July 20, 2023 19:23
@atugushev atugushev requested a review from AndydeCleyre July 20, 2023 20:16
@webknjaz
Copy link
Member

FWIW it might be useful to run mypy against several pip and Python versions (like min + max). Just the last one isn't going to cover a lot of stuff..

@atugushev
Copy link
Member Author

FWIW it might be useful to run mypy against several pip and Python versions (like min + max). Just the last one isn't going to cover a lot of stuff..

@webknjaz I wonder if there are any library/apps in wild that do this?

@webknjaz
Copy link
Member

Pip itself used to have py3 and py2 runs both in pre-commit, before 2020. I also do so in some places (like Cheroot). One possible strategy is to test every other version or min/max to cover most stuff while still not using too much resources.
I think that ansible-test runs mypy under every supported interpreter version (both for the ansible-core itself and the external collections).

@webknjaz
Copy link
Member

webknjaz commented Jul 21, 2023

pre-commit tip: if you add several check invocations, it's important to add aliases because several checks have the same id and there's no way to select a specific check without this.

@atugushev
Copy link
Member Author

atugushev commented Jul 21, 2023

I also do so in some places (like Cheroot)

@webknjaz how do you handle type incompatibilities between different versions in the same code?

@atugushev atugushev closed this Jul 21, 2023
@atugushev atugushev reopened this Jul 21, 2023
@atugushev

This comment was marked as resolved.

@atugushev
Copy link
Member Author

FWIW it might be useful to run mypy against several pip and Python versions (like min + max). Just the last one isn't going to cover a lot of stuff..

@webknjaz opened a separate issue #1928 to address the suggestion.

Comment on lines +31 to +33
- click==8.1.6
- pip==23.2
- build==0.10.0
Copy link
Contributor

Choose a reason for hiding this comment

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

We haven't got these requirements pinned in pyproject.toml - Should we do this, or instead remove the boundary here?

Copy link
Member

Choose a reason for hiding this comment

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

@chrysle this is kinda a special case. https://pre-commit.ci is heavily cached and the cache virtually never expires. Locally we can use a pre-commit subcommand to clean it but no in the CI service. This kinda forces us to have something that would update in the cache key. But also, not having pins will cause difference in behavior on people's machines depending on when they first ran pre-commit and got the env cached.

@chrysle chrysle requested a review from webknjaz January 6, 2024 08:13
@webknjaz
Copy link
Member

webknjaz commented Nov 5, 2025

how do you handle type incompatibilities between different versions in the same code?

MyPy's assert-based type narrowing can handle this. Though, there might be the need to have multiple MyPy invocations running against different versions of pip pinned.

@webknjaz webknjaz requested review from sirosen and removed request for webknjaz November 5, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants