Skip to content

PEP 612: hide from those who may seek to use it #9874

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

Merged
merged 1 commit into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ def add_invertible_flag(flag: str,
# Must be followed by another flag or by '--' (and then only file args may follow).
parser.add_argument('--cache-map', nargs='+', dest='special-opts:cache_map',
help=argparse.SUPPRESS)
# PEP 612 support is a work in progress, hide it from users
parser.add_argument('--wip-pep-612', action="store_true", help=argparse.SUPPRESS)

# options specifying code to check
code_group = parser.add_argument_group(
Expand Down
3 changes: 3 additions & 0 deletions mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ def __init__(self) -> None:
# mypy. (Like mypyc.)
self.preserve_asts = False

# PEP 612 support is a work in progress, hide it from users
self.wip_pep_612 = False

# Paths of user plugins
self.plugins = [] # type: List[str]

Expand Down
2 changes: 2 additions & 0 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3106,6 +3106,8 @@ def process_paramspec_declaration(self, s: AssignmentStmt) -> bool:
In the future, ParamSpec may accept bounds and variance arguments, in which
case more aggressive sharing of code with process_typevar_declaration should be pursued.
"""
if not self.options.wip_pep_612:
return False
call = self.get_typevarlike_declaration(
s, ("typing_extensions.ParamSpec", "typing.ParamSpec")
)
Expand Down
2 changes: 2 additions & 0 deletions test-data/unit/check-parameter-specification.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[case testBasicParamSpec]
# flags: --wip-pep-612
from typing_extensions import ParamSpec
P = ParamSpec('P')
[builtins fixtures/tuple.pyi]

[case testParamSpecLocations]
# flags: --wip-pep-612
from typing import Callable, List
from typing_extensions import ParamSpec, Concatenate
P = ParamSpec('P')
Expand Down
1 change: 1 addition & 0 deletions test-data/unit/semanal-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ def g() -> None:
[out]

[case testParamSpec]
# flags: --wip-pep-612
from typing_extensions import ParamSpec

TParams = ParamSpec('TParams')
Expand Down
7 changes: 4 additions & 3 deletions test-data/unit/semanal-types.test
Original file line number Diff line number Diff line change
Expand Up @@ -1500,11 +1500,12 @@ MypyFile:1(


[case testParamSpec]
# flags: --wip-pep-612
from typing import ParamSpec
P = ParamSpec("P")
[out]
MypyFile:1(
ImportFrom:1(typing, [ParamSpec])
AssignmentStmt:2(
ImportFrom:2(typing, [ParamSpec])
AssignmentStmt:3(
NameExpr(P* [__main__.P])
ParamSpecExpr:2()))
ParamSpecExpr:3()))