GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-96130: Rephrase use of "typecheck" verb for clarity by hauntsaninja · Pull Request #98144 · python/cpython

gh-96130: Rephrase use of "typecheck" verb for clarity #98144

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.

Sign up for GitHub

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

Merged
JelleZijlstra merged 1 commit into python:main from hauntsaninja:gh-96130
Oct 12, 2022

Uh oh!

There was an error while loading. Please reload this page.

Merged

gh-96130: Rephrase use of "typecheck" verb for clarity #98144

Changes from all commits
Commits
Show all changes
1 commit
Select commit
48ddbb2
gh-96130: Rephrase use of "typecheck" verb for clarity
hauntsaninja Oct 10, 2022
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

20 changes: 10 additions & 10 deletions 20 Doc/library/typing.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ A type alias is defined by assigning the type to the alias. In this example,
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]

# typechecks; a list of floats qualifies as a Vector.
# passes type checking; a list of floats qualifies as a Vector.
new_vector = scale(2.0, [1.0, -4.2, 5.4])

Type aliases are useful for simplifying complex type signatures. For example::
Expand Down Expand Up @@ -147,10 +147,10 @@ of the original type. This is useful in helping catch logical errors::
def get_user_name(user_id: UserId) -> str:
...

# typechecks
# passes type checking
user_a = get_user_name(UserId(42351))

# does not typecheck; an int is not a UserId
# fails type checking; an int is not a UserId
user_b = get_user_name(-1)

You may still perform all ``int`` operations on a variable of type ``UserId``,
Expand All @@ -176,7 +176,7 @@ It is invalid to create a subtype of ``Derived``::

UserId = NewType('UserId', int)

# Fails at runtime and does not typecheck
# Fails at runtime and does not pass type checking
class AdminUserId(UserId): pass

However, it is possible to create a :class:`NewType` based on a 'derived' ``NewType``::
Expand Down Expand Up @@ -463,12 +463,12 @@ value of type :data:`Any` and assign it to any variable::
s = a # OK

def foo(item: Any) -> int:
# Typechecks; 'item' could be any type,
# Passes type checking; 'item' could be any type,
# and that type might have a 'bar' method
item.bar()
...

Notice that no typechecking is performed when assigning a value of type
Notice that no type checking is performed when assigning a value of type
:data:`Any` to a more precise type. For example, the static type checker did
not report an error when assigning ``a`` to ``s`` even though ``s`` was
declared to be of type :class:`str` and receives an :class:`int` value at
Expand Down Expand Up @@ -500,20 +500,20 @@ reject almost all operations on it, and assigning it to a variable (or using
it as a return value) of a more specialized type is a type error. For example::

def hash_a(item: object) -> int:
# Fails; an object does not have a 'magic' method.
# Fails type checking; an object does not have a 'magic' method.
item.magic()
...

def hash_b(item: Any) -> int:
# Typechecks
# Passes type checking
item.magic()
...

# Typechecks, since ints and strs are subclasses of object
# Passes type checking, since ints and strs are subclasses of object
hash_a(42)
hash_a("foo")

# Typechecks, since Any is compatible with all types
# Passes type checking, since Any is compatible with all types
hash_b(42)
hash_b("foo")

Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.