Skip to content

The term "typechecks" is confusingly used as an adjective #96130

Description

@ketozhang

Documentation

Arguably to new eyes, you can mistaken "typecheck" to be a verb meaning "to do type checking". I understand this term came from the C function TypeCheck that returns a boolean.

Activity

  1. ketozhang commented on Aug 19, 2022

    @ketozhang
    Author

    It's particular confusing in NewType https://docs.python.org/3.10/library/typing.html#newtype

    The static type checker will treat the new type as if it were a subclass of the original type. This is useful in helping catch logical errors:

    def get_user_name(user_id: UserId) -> str:
        ...
    
    # typechecks
    user_a = get_user_name(UserId(42351))
    
    # does not typecheck; an int is not a UserId
    user_b = get_user_name(-1)

    The last two line may mean, the type checker skips checking this line.

  2. ericvsmith commented on Aug 19, 2022

    @ericvsmith
    Member

    Do you have a proposal to improve this? I think it’s okay as-is, but if you can make it better that would be good.

  3. ketozhang commented on Aug 22, 2022

    @ketozhang
    Author

    I believe "Passes type checking" and "Fails type checking" is very clear.

  4. ericvsmith commented on Aug 22, 2022

    @ericvsmith
    Member

    I believe "Passes type checking" and "Fails type checking" is very clear.

    Agreed!

  5. added a commit that references this issue on Oct 10, 2022
  6. added a commit that references this issue on Oct 12, 2022
  7. added 2 commits that reference this issue on Oct 12, 2022
  8. JelleZijlstra commented on Oct 12, 2022

    @JelleZijlstra
    Member

    Thanks @ketozhang for the report and @hauntsaninja for the fix!

  9. added 2 commits that reference this issue on Oct 12, 2022
  10. added a commit that references this issue on Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions