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

Add protocol type BaseVersion #400

Closed
wants to merge 1 commit into from
Closed

Add protocol type BaseVersion #400

wants to merge 1 commit into from

Commits on Feb 11, 2021

  1. Add protocol type BaseVersion

    This allows mypy to know about all available properties when APIs return
    any Version type.
    
    For example, the pip project defines functions that return a
    _BaseVersion instance. One example is:
    
    https://github.com/pypa/pip/blob/bbf8466088655d22cd46b286c8f0b8150754c1d9/src/pip/_internal/metadata/base.py#L24
    
    Downstream projects, such as pip-tools, use mypy to help verify correct
    API use. pip-tools then calls methods on the _BaseVersion instance which
    reports:
    
        "_BaseVersion" has no attribute "is_prerelease"
    
    By defining the protocol, pip and other libraries can use use its typing
    information and it will be more useful to more projects.
    jdufresne committed Feb 11, 2021
    Configuration menu
    Copy the full SHA
    d72a429 View commit details
    Browse the repository at this point in the history