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 — Limit binder special-casing to imprecise Any by ilevkivskyi · Pull Request #22050 · python/mypy

Limit binder special-casing to imprecise Any #22050

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
ilevkivskyi merged 4 commits into python:master from ilevkivskyi:better-binder-any
Sep 28, 2026

Uh oh!

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

Merged

Limit binder special-casing to imprecise Any #22050

Changes from 1 commit
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
e0a60ec
Limit binder special-casing to imprecise Any
ilevkivskyi Sep 25, 2026
6837346
Keep reverse logic
ilevkivskyi Sep 25, 2026
0151e5d
Merge remote-tracking branch 'upstream/master' into better-binder-any
ilevkivskyi Sep 28, 2026
6aee713
Add dedicated tests
ilevkivskyi Sep 28, 2026
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
Prev Previous commit
Add dedicated tests
  • Loading branch information

Uh oh!

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

@ilevkivskyi
ilevkivskyi committed Sep 28, 2026
commit 6aee71352f19c19e662833d75e5b46fb531cf858

There are no files selected for viewing

47 changes: 47 additions & 0 deletions 47 test-data/unit/check-narrowing.test
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4299,3 +4299,50 @@ def func(y: H) -> H:
else:
return y
[builtins fixtures/primitives.pyi]

[case testNarrowingToAnyDifferentKinds]
# flags: --ignore-missing-imports
from typing import Any
from whatever import Unimported

explicit: Any

def foo(): ...
imprecise = foo()
unimported: Unimported

x: int
if int():
x = explicit
reveal_type(x) # N: Revealed type is "Any"

y: int
if int():
y = from_error # type: ignore
reveal_type(y) # N: Revealed type is "Any"

x1: int
if int():
x1 = imprecise
reveal_type(x1) # N: Revealed type is "builtins.int"

y1: int
if int():
y1 = unimported
reveal_type(y) # N: Revealed type is "builtins.int"

[case testNarrowingToImpreciseAnyFromUnionWithExplicit]
from typing import Any, Union

def foo(): ...
imprecise = foo()

x: Union[Any, int]
if int():
x = imprecise
reveal_type(x) # N: Revealed type is "Any"

y: Union[str, int]
if int():
y = imprecise
reveal_type(y) # N: Revealed type is "builtins.str | builtins.int"
Loading
Oops, something went wrong.

Uh oh!

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

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 01402792 — 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.