basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

Allow `Typevar`s in the `bound`s of `TypeVar`s

Open KotlinIsland opened this issue 3 years ago • 2 comments

TODO: tests, documentation

KotlinIsland avatar Jul 30 '22 03:07 KotlinIsland

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Jul 30 '22 10:07 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Jul 30 '22 10:07 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 07 '22 14:08 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 07 '22 20:08 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 11 '22 13:08 github-actions[bot]

TODO: constraints

in this PR or a seperate one? is there an issue for ir

DetachHead avatar Aug 14 '22 06:08 DetachHead

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

materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/cli/optbench.py:92:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:92:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:93:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:93:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:94:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:94:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:119:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:119:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:120:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:120:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:121:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:121:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:122:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:122:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:123:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:123:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:124:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:124:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:45:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:45:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:51:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:51:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:56:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:56:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]

jax (https://github.com/google/jax)
- jax/_src/config.py:520:9: error: Invalid self argument "_ThreadLocalExtraJitContext" to attribute function "_replace" with type "[_NT: (Any | None, Hashable | None, str | None, str | None, Any | None, bool)] (_NT, DefaultNamedArg(Any | None, 'dynamic_trace_state'), DefaultNamedArg(Hashable, 'axis_env_state'), DefaultNamedArg(str | None, 'numpy_rank_promotion'), DefaultNamedArg(str | None, 'numpy_dtype_promotion'), DefaultNamedArg(Any | None, 'default_matmul_precision'), DefaultNamedArg(bool, 'dynamic_shapes')) -> _NT"  [misc]
+ jax/_src/config.py:520:9: error: Invalid self argument "_ThreadLocalExtraJitContext" to attribute function "_replace" with type "[_NT: (Any | None, Hashable, str | None, str | None, Any | None, bool)] (_NT, DefaultNamedArg(Any | None, 'dynamic_trace_state'), DefaultNamedArg(Hashable, 'axis_env_state'), DefaultNamedArg(str | None, 'numpy_rank_promotion'), DefaultNamedArg(str | None, 'numpy_dtype_promotion'), DefaultNamedArg(Any | None, 'default_matmul_precision'), DefaultNamedArg(bool, 'dynamic_shapes')) -> _NT"  [misc]

github-actions[bot] avatar Aug 14 '22 10:08 github-actions[bot]

TODO: constraints

in this PR or a seperate one? is there an issue for ir

sorry about that, I've got some eggs of constraints and I'll working though them now.

KotlinIsland avatar Aug 14 '22 11:08 KotlinIsland

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

materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/cli/optbench.py:92:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:92:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:93:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:93:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:94:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:94:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:119:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:119:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:120:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:120:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:121:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:121:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:122:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:122:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:123:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:123:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:124:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:124:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:45:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:45:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:51:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:51:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:56:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:56:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]

jax (https://github.com/google/jax)
- jax/_src/config.py:520:9: error: Invalid self argument "_ThreadLocalExtraJitContext" to attribute function "_replace" with type "[_NT: (Any | None, Hashable | None, str | None, str | None, Any | None, bool)] (_NT, DefaultNamedArg(Any | None, 'dynamic_trace_state'), DefaultNamedArg(Hashable, 'axis_env_state'), DefaultNamedArg(str | None, 'numpy_rank_promotion'), DefaultNamedArg(str | None, 'numpy_dtype_promotion'), DefaultNamedArg(Any | None, 'default_matmul_precision'), DefaultNamedArg(bool, 'dynamic_shapes')) -> _NT"  [misc]
+ jax/_src/config.py:520:9: error: Invalid self argument "_ThreadLocalExtraJitContext" to attribute function "_replace" with type "[_NT: (Any | None, Hashable, str | None, str | None, Any | None, bool)] (_NT, DefaultNamedArg(Any | None, 'dynamic_trace_state'), DefaultNamedArg(Hashable, 'axis_env_state'), DefaultNamedArg(str | None, 'numpy_rank_promotion'), DefaultNamedArg(str | None, 'numpy_dtype_promotion'), DefaultNamedArg(Any | None, 'default_matmul_precision'), DefaultNamedArg(bool, 'dynamic_shapes')) -> _NT"  [misc]

github-actions[bot] avatar Aug 14 '22 11:08 github-actions[bot]

Actually, it's MVP now, constraints might be much harder.

KotlinIsland avatar Aug 14 '22 22:08 KotlinIsland

The primer diff is due to some new calls that are simplifying the union in the upper bound, i.e. object | int becomes object.

KotlinIsland avatar Aug 15 '22 02:08 KotlinIsland

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

materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/cli/optbench.py:92:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:92:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:93:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:93:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:94:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:94:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:119:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:119:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:120:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:120:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:121:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:121:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:122:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:122:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:123:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:123:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/optbench.py:124:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/optbench.py:124:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:45:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:45:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:51:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:51:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]
- misc/python/materialize/cli/crate_diagram.py:56:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any | Command] (FC) -> FC")  [no-any-expr]
+ misc/python/materialize/cli/crate_diagram.py:56:2: error: Expression type contains "Any" (has type "[FC: (...) -> Any] (FC) -> FC")  [no-any-expr]

jax (https://github.com/google/jax)
- jax/_src/config.py:520:9: error: Invalid self argument "_ThreadLocalExtraJitContext" to attribute function "_replace" with type "[_NT: (Any | None, Hashable | None, str | None, str | None, Any | None, bool)] (_NT, DefaultNamedArg(Any | None, 'dynamic_trace_state'), DefaultNamedArg(Hashable, 'axis_env_state'), DefaultNamedArg(str | None, 'numpy_rank_promotion'), DefaultNamedArg(str | None, 'numpy_dtype_promotion'), DefaultNamedArg(Any | None, 'default_matmul_precision'), DefaultNamedArg(bool, 'dynamic_shapes')) -> _NT"  [misc]
+ jax/_src/config.py:520:9: error: Invalid self argument "_ThreadLocalExtraJitContext" to attribute function "_replace" with type "[_NT: (Any | None, Hashable, str | None, str | None, Any | None, bool)] (_NT, DefaultNamedArg(Any | None, 'dynamic_trace_state'), DefaultNamedArg(Hashable, 'axis_env_state'), DefaultNamedArg(str | None, 'numpy_rank_promotion'), DefaultNamedArg(str | None, 'numpy_dtype_promotion'), DefaultNamedArg(Any | None, 'default_matmul_precision'), DefaultNamedArg(bool, 'dynamic_shapes')) -> _NT"  [misc]

github-actions[bot] avatar Aug 15 '22 10:08 github-actions[bot]