Skip to content

Simplify bool stub #6782

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

Closed
wants to merge 1 commit into from
Closed

Simplify bool stub #6782

wants to merge 1 commit into from

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jan 2, 2022

The semantics of this proposed revision should be identical to the existing stub. I'm curious, though, to see whether primer shows false-positives like those we saw in #6762

The semantics of this proposed PR should be identical to the existing stub. I'm curious, though, to see whether primer shows false-positives like those we saw in python#6762
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2022

Diff from mypy_primer, showing the effect of this PR on open source code:

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/ops/mask_ops.py:58: error: Value of type variable "_B" of "__or__" of "bool" cannot be "ndarray[Any, Any]"  [type-var]
+ pandas/core/ops/mask_ops.py:181: error: Value of type variable "_B" of "__or__" of "bool" cannot be "ndarray[Any, Any]"  [type-var]
+ pandas/core/groupby/indexing.py:163: error: Value of type variable "_B" of "__or__" of "bool" cannot be "ndarray[Any, dtype[bool_]]"  [type-var]
+ pandas/core/groupby/indexing.py:166: error: Value of type variable "_B" of "__or__" of "bool" cannot be "ndarray[Any, dtype[bool_]]"  [type-var]
+ pandas/core/groupby/indexing.py:175: error: Value of type variable "_B" of "__or__" of "bool" cannot be "ndarray[Any, Any]"  [type-var]
+ pandas/core/groupby/indexing.py:177: error: Value of type variable "_B" of "__or__" of "bool" cannot be "Union[bool, ndarray[Any, Any]]"  [type-var]

@AlexWaygood
Copy link
Member Author

I'll take a look at the pandas errors in more detail later.

@@ -75,6 +75,7 @@ _TBE = TypeVar("_TBE", bound="BaseException")
_R = TypeVar("_R") # Return-type TypeVar
_SupportsNextT = TypeVar("_SupportsNextT", bound=SupportsNext[Any], covariant=True)
_SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant=True)
_B = TypeVar("_B", bool, int)
Copy link
Member

Choose a reason for hiding this comment

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

In my experience mypy does not have ideal support for TypeVars with values (and bugs in this field are really hard to fix!). It might be the root cause in pandas case.

@srittau srittau added the status: deferred Issue or PR deferred until some precondition is fixed label Jan 2, 2022
@srittau
Copy link
Collaborator

srittau commented Jan 2, 2022

Also marking as "deferred" due to mypy problems.

@AlexWaygood
Copy link
Member Author

Also marking as "deferred" due to mypy problems.

Agreed, this definitely shouldn't be merged until the errors identified in #6762 are resolved (if at all).

@hauntsaninja
Copy link
Collaborator

This is likely the exact same thing as python/mypy#11880 from the other day

@JelleZijlstra
Copy link
Member

Seems like this causes new false positives and doesn't actually solve any problem, so maybe we should just close this. (Trying to keep down the list of open PRs.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: deferred Issue or PR deferred until some precondition is fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants