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 — bpo-46644: Remove callable() requirement from typing._type_check by GBeauregard · Pull Request #31151 · python/cpython

Conversation

@GBeauregard

@GBeauregard GBeauregard commented Feb 5, 2022 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

We remove tests that check for int literals. A check that a type isn't a tuple literal was added to cover cases like Final[int, str]. This codepath wasn't covered for TypeGuard so I added a test for it. Note we already disallow tuple types since things like Union[typeform]->typeform, but Union[typeform, typeform] -> Union[typeform, typeform].

https://bugs.python.org/issue46644

Sorry, something went wrong.

Uh oh!

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

All reactions
GBeauregard added 3 commits February 5, 2022 13:23
@GBeauregard
remove callable() check from typing._type_check
6631801
We also remove all the tests that check for integer literals
@GBeauregard
add tuple check: covers cases like Final[int, str]
bff7b6e
@GBeauregard
remove list literal type checks
8e98706
@GBeauregard
GBeauregard marked this pull request as ready for review February 5, 2022 22:10
@blurb-it
📜🤖 Added by blurb_it.
43a19bb
@GBeauregard GBeauregard changed the title bpo-46644: Remove type check callable bpo-46644: Remove callable() requirement from typing._type_check Feb 5, 2022
@GBeauregard
remove list of types exempt from callable check
6c20542
@bedevere-bot bedevere-bot added the awaiting review label Feb 5, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 5, 2022
@GBeauregard
GBeauregard requested review from Fidget-Spinner and gvanrossum as code owners February 5, 2022 22:52
JelleZijlstra
JelleZijlstra reviewed Feb 6, 2022
View reviewed changes
Comment thread Lib/test/test_types.py Resolved

Uh oh!

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

Comment thread Lib/test/test_typing.py Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Library/2022-02-05-22-14-44.bpo-46644.P--1Cz.rst Resolved

Uh oh!

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

@GBeauregard GBeauregard mentioned this pull request Feb 6, 2022
bpo-44796: Unify TypeVar and ParamSpec substitution #31143
Merged
GBeauregard added 2 commits February 5, 2022 17:57
@GBeauregard
add alternative tests
2dbab97
@GBeauregard
Update 2022-02-05-22-14-44.bpo-46644.P--1Cz.rst
fdcc441
@GBeauregard
GBeauregard requested a review from JelleZijlstra February 6, 2022 02:02
JelleZijlstra
JelleZijlstra approved these changes Feb 6, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting core review and removed awaiting review labels Feb 6, 2022
@GBeauregard
Merge branch 'python:main' into remove-type-check-callable
3b6e830
@GBeauregard GBeauregard mentioned this pull request Feb 6, 2022
bpo-46644: No longer accept arbitrary callables as type arguments in generics #31159
Closed
@gvanrossum

gvanrossum commented Feb 7, 2022

Copy link
Copy Markdown
Member

Since there is still discussion going on in bpo this should not yet be merged.

All reactions

Sorry, something went wrong.

Uh oh!

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

JelleZijlstra
JelleZijlstra approved these changes Mar 10, 2022
View reviewed changes

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I still think we should move forward with this change and close the alternative #31159 (cc @gvanrossum @Fidget-Spinner @serhiy-storchaka). Being permissive in the typing.py runtime helps make innovation in the type system possible.

PEP 612 and 646 were difficult to implement in typing-extensions because of overly strict checks in typing.py (e.g. https://github.com/python/typing/blob/95c9c2bab2034f0359e8457360d93a288a65e55d/typing_extensions/src/typing_extensions.py#L1860, https://github.com/python/typing/blob/95c9c2bab2034f0359e8457360d93a288a65e55d/typing_extensions/src/typing_extensions.py#L1900). To make future PEPs easier to implement, I want to generally keep runtime checks in typing.py at a minimum. This PR removes a check that has been particularly problematic.

Sorry, something went wrong.

Uh oh!

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

AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Mar 10, 2022
@JelleZijlstra
Merge branch 'main' into remove-type-check-callable
2555a41
gvanrossum
gvanrossum approved these changes Mar 10, 2022
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes, that’s fair. Godspeed!

Sorry, something went wrong.

Uh oh!

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

All reactions
@JelleZijlstra JelleZijlstra self-assigned this Mar 10, 2022
Fidget-Spinner
Fidget-Spinner approved these changes Mar 10, 2022
View reviewed changes

@Fidget-Spinner Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. Feel free to ignore my comment below.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Misc/NEWS.d/next/Library/2022-02-05-22-14-44.bpo-46644.P--1Cz.rst
@@ -0,0 +1 @@
No longer require valid typeforms to be callable. This allows :data:`typing.Annotated` to wrap :data:`typing.ParamSpecArgs` and :data:`dataclasses.InitVar`. Patch by Gregory Beauregard.

@Fidget-Spinner Fidget-Spinner Mar 10, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Each line should be under 80 chars. However since this is usually merged into the next release's changelog anyways I'm not sure if it matters.

Sorry, something went wrong.

Uh oh!

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

All reactions

@JelleZijlstra JelleZijlstra Mar 10, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes, I think blurb takes care of that when it generates the full changelog.

Sorry, something went wrong.

Uh oh!

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

All reactions
@JelleZijlstra
JelleZijlstra merged commit 870b22b into python:main Mar 12, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Mar 12, 2022
JelleZijlstra added a commit that referenced this pull request Mar 12, 2022
@JelleZijlstra
bpo-46644: Fix test_typing test broken by GH-31151 due to a merge race (
7517437
GH-31833)
@GBeauregard GBeauregard mentioned this pull request Mar 19, 2022
gh-90669: Let typing.Annotated wrap dataclasses annotations #30997
Open
@JelleZijlstra JelleZijlstra mentioned this pull request Apr 13, 2022
Add typing to 3.11 What's New #91491
Closed
@Fidget-Spinner Fidget-Spinner mentioned this pull request May 10, 2022
typing._type_check no longer recognizes several kinds of non-types #92601
Closed
@JelleZijlstra JelleZijlstra mentioned this pull request Sep 14, 2022
test_typeddict_errors fails on python3.11 python/mypy_extensions#24
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@gvanrossum gvanrossum gvanrossum approved these changes
@Fidget-Spinner Fidget-Spinner Fidget-Spinner approved these changes

Uh oh!

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

Assignees

@JelleZijlstra JelleZijlstra

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

6 participants

@GBeauregard @gvanrossum @JelleZijlstra @Fidget-Spinner @the-knights-who-say-ni @bedevere-bot
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 01402503 — 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.