GeezerVison is showing github.com — TypeForm: Enable by default by davidfstr · Pull Request #21262 · python/mypy
TypeForm: Enable by default
#21262
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
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter
Filter by extension
.py
(3)
.rst
(1)
.test
(2)
All 3 file types selected
Viewed files
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
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1174,7 +1174,7 @@ format into the specified directory.
Enabling incomplete/experimental features
*****************************************
.. option:: --enable-incomplete-feature {PreciseTupleTypes,InlineTypedDict,TypeForm }
.. option:: --enable-incomplete-feature {PreciseTupleTypes,InlineTypedDict}
Some features may require several mypy releases to implement, for example
due to their complexity, potential for backwards incompatibility, or
Expand Down
Expand Up
@@ -1229,8 +1229,6 @@ List of currently incomplete/experimental features:
def test_values() -> {"width": int, "description": str}:
return {"width": 42, "description": "test"}
* ``TypeForm``: this feature enables ``TypeForm``, as described in
`PEP 747 – Annotating Type Forms <https://peps.python.org/pep-0747/>_`.
Miscellaneous
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -93,8 +93,8 @@ class BuildType:
NEW_GENERIC_SYNTAX: Final = "NewGenericSyntax"
INLINE_TYPEDDICT: Final = "InlineTypedDict"
TYPE_FORM: Final = "TypeForm"
INCOMPLETE_FEATURES: Final = frozenset((PRECISE_TUPLE_TYPES, INLINE_TYPEDDICT, TYPE_FORM ))
COMPLETE_FEATURES: Final = frozenset((TYPE_VAR_TUPLE, UNPACK, NEW_GENERIC_SYNTAX))
INCOMPLETE_FEATURES: Final = frozenset((PRECISE_TUPLE_TYPES, INLINE_TYPEDDICT))
COMPLETE_FEATURES: Final = frozenset((TYPE_VAR_TUPLE, UNPACK, NEW_GENERIC_SYNTAX, TYPE_FORM ))
class Options:
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -195,7 +195,7 @@
type_aliases_source_versions,
typing_extensions_aliases,
)
from mypy.options import TYPE_FORM, Options
from mypy.options import Options
from mypy.patterns import (
AsPattern,
ClassPattern,
Expand Down
Expand Up
@@ -3701,8 +3701,7 @@ def analyze_lvalues(self, s: AssignmentStmt) -> None:
)
def analyze_rvalue_as_type_form(self, s: AssignmentStmt) -> None:
if TYPE_FORM in self.options.enable_incomplete_feature:
self.try_parse_as_type_expression(s.rvalue)
self.try_parse_as_type_expression(s.rvalue)
def apply_dynamic_class_hook(self, s: AssignmentStmt) -> None:
if not isinstance(s.rvalue, CallExpr):
Expand Down
Expand Up
@@ -5452,8 +5451,7 @@ def visit_return_stmt(self, s: ReturnStmt) -> None:
self.fail('"return" not allowed in except* block', s, serious=True)
if s.expr:
s.expr.accept(self)
if TYPE_FORM in self.options.enable_incomplete_feature:
self.try_parse_as_type_expression(s.expr)
self.try_parse_as_type_expression(s.expr)
self.statement = old
def visit_raise_stmt(self, s: RaiseStmt) -> None:
Expand Down
Expand Up
@@ -6056,11 +6054,9 @@ def visit_call_expr(self, expr: CallExpr) -> None:
expr.analyzed.accept(self)
else:
# Normal call expression.
calculate_type_forms = TYPE_FORM in self.options.enable_incomplete_feature
for a in expr.args:
a.accept(self)
if calculate_type_forms:
self.try_parse_as_type_expression(a)
self.try_parse_as_type_expression(a)
if (
isinstance(expr.callee, MemberExpr)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -49,7 +49,7 @@
check_arg_kinds,
check_param_names,
)
from mypy.options import INLINE_TYPEDDICT, TYPE_FORM, Options
from mypy.options import INLINE_TYPEDDICT, Options
from mypy.plugin import AnalyzeTypeContext, Plugin, TypeAnalyzerPluginInterface
from mypy.semanal_shared import (
SemanticAnalyzerCoreInterface,
Expand Down
Expand Up
@@ -674,12 +674,6 @@ def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Typ
item = AnyType(TypeOfAny.from_error)
return TypeType.make_normalized(item, line=t.line, column=t.column)
elif fullname in ("typing_extensions.TypeForm", "typing.TypeForm"):
if TYPE_FORM not in self.options.enable_incomplete_feature:
self.fail(
"TypeForm is experimental,"
" must be enabled with --enable-incomplete-feature=TypeForm",
t,
)
if len(t.args) == 0:
any_type = self.get_omitted_any(t)
return TypeType(any_type, line=t.line, column=t.column, is_type_form=True)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -337,7 +337,7 @@ def call() -> str: pass
[builtins fixtures/module.pyi]
[case testInvalidEscapeSequenceWarningsSuppressed]
# flags: --python-version 3.14 --enable-incomplete-feature=TypeForm
# flags: --python-version 3.15
# Test that SyntaxWarnings for invalid escape sequences are suppressed
# when parsing potential type expressions containing regex patterns or
# similar strings. Callable arguments are always potential type expressions.
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.