diff --git a/CHANGELOG b/CHANGELOG index e40e9935e..6a33b2f5b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,13 @@ +Version 2023.11.29: + +Updates: +* Remove the --use-enum-overlay flag. It has been enabled by default since the + last release. + +Bug fixes: +* Mark typing.Required as generic. +* Fix container mutation bug. + Version 2023.11.21: Updates: diff --git a/docs/support.md b/docs/support.md index 4c86dc34f..76a164e2a 100644 --- a/docs/support.md +++ b/docs/support.md @@ -17,7 +17,7 @@ of pytype. * [Third-Party Libraries](#third-party-libraries) - + @@ -53,14 +53,12 @@ Note: pytype supports all language and stdlib features in its supported versions unless noted otherwise. This section lists features that are difficult to type for which pytype has or intends to add custom support. -| Feature | Supports | Issues | -| ---------------------------- | :------: | :--------------------------------: | -| Control Flow Analysis ("Type | ✅ | | -: Narrowing") : : : -| collections.namedtuple | ✅ | | -| Dataclasses | ✅ | | -| Enums | ✅ | Requires `--use-enum-overlay` flag | -: : : externally : +Feature | Supports | Issues +---------------------------------------- | :------: | :----: +Control Flow Analysis ("Type Narrowing") | ✅ | +collections.namedtuple | ✅ | +Dataclasses | ✅ | +Enums | ✅ | ### Typing diff --git a/pytype/__version__.py b/pytype/__version__.py index 9ccfc3f5f..c97ee47a1 100644 --- a/pytype/__version__.py +++ b/pytype/__version__.py @@ -1,2 +1,2 @@ # pylint: skip-file -__version__ = '2023.11.21' +__version__ = '2023.11.29' diff --git a/pytype/abstract/_special_classes.py b/pytype/abstract/_special_classes.py index 6326a805d..b1d54c709 100644 --- a/pytype/abstract/_special_classes.py +++ b/pytype/abstract/_special_classes.py @@ -12,7 +12,7 @@ def build_class(node, props, kwargs, ctx): base = abstract_utils.get_atomic_value(base, default=None) if not isinstance(base, class_mixin.Class): continue - if base.is_enum and ctx.options.use_enum_overlay: + if base.is_enum: enum_base = abstract_utils.get_atomic_value( ctx.vm.loaded_overlays["enum"].members["Enum"]) return enum_base.make_class(node, props) diff --git a/pytype/config.py b/pytype/config.py index 30b3ee31f..70f656df3 100644 --- a/pytype/config.py +++ b/pytype/config.py @@ -242,8 +242,6 @@ def add_options(o, arglist): _flag("--overriding-renamed-parameter-count-checks", False, "Enable parameter count checks for overriding methods with " "renamed arguments."), - _flag("--use-enum-overlay", True, - "Use the enum overlay for more precise enum checking."), _flag("--strict-none-binding", False, "Variables initialized as None retain their None binding."), _flag("--use-fiddle-overlay", False, diff --git a/pytype/output.py b/pytype/output.py index 69272bc0a..348e94d4e 100644 --- a/pytype/output.py +++ b/pytype/output.py @@ -813,7 +813,7 @@ def fix(sig): # replace any parameter not in the class or function template with # its upper value. methods[name] = method.Visit(visitors.DropMutableParameters()) - elif v.is_enum and self.ctx.options.use_enum_overlay: + elif v.is_enum: if (any( isinstance(enum_member, abstract.Instance) and enum_member.cls == v for enum_member in member.data)): diff --git a/pytype/overlays/enum_overlay.py b/pytype/overlays/enum_overlay.py index 0aa630830..5325d2e11 100644 --- a/pytype/overlays/enum_overlay.py +++ b/pytype/overlays/enum_overlay.py @@ -52,18 +52,15 @@ class EnumOverlay(overlay.Overlay): """An overlay for the enum std lib module.""" def __init__(self, ctx): - if ctx.options.use_enum_overlay: - member_map = { - "Enum": overlay.add_name("Enum", EnumBuilder), - "EnumMeta": EnumMeta, - "EnumType": EnumMeta, - "IntEnum": overlay.add_name("IntEnum", EnumBuilder), - "StrEnum": overlay.add_name("StrEnum", EnumBuilder), - **{name: overlay.add_name(name, overlay_utils.not_supported_yet) - for name in _unsupported}, - } - else: - member_map = {} + member_map = { + "Enum": overlay.add_name("Enum", EnumBuilder), + "EnumMeta": EnumMeta, + "EnumType": EnumMeta, + "IntEnum": overlay.add_name("IntEnum", EnumBuilder), + "StrEnum": overlay.add_name("StrEnum", EnumBuilder), + **{name: overlay.add_name(name, overlay_utils.not_supported_yet) + for name in _unsupported}, + } super().__init__(ctx, "enum", member_map, ctx.loader.import_name("enum")) diff --git a/pytype/tests/test_base.py b/pytype/tests/test_base.py index 3c8d03a86..f6a2f111d 100644 --- a/pytype/tests/test_base.py +++ b/pytype/tests/test_base.py @@ -86,7 +86,6 @@ def setUp(self): strict_undefined_checks=True, strict_primitive_comparisons=True, strict_none_binding=True, - use_enum_overlay=True, use_fiddle_overlay=True, validate_version=False, ) diff --git a/pytype/tests/test_pyi2.py b/pytype/tests/test_pyi2.py index 55503f394..280edfa78 100644 --- a/pytype/tests/test_pyi2.py +++ b/pytype/tests/test_pyi2.py @@ -7,7 +7,7 @@ class PYITest(test_base.BaseTest): """Tests for PYI.""" - def test_unneccessary_any_import(self): + def test_unnecessary_any_import(self): ty = self.Infer(""" import typing def foo(**kwargs: typing.Any) -> int: return 1 @@ -153,7 +153,6 @@ def test_imported_literal_alias(self): """) def test_literal_in_dataclass(self): - self.options.tweak(use_enum_overlay=False) with self.DepTree([("foo.pyi", """ import enum class Base: ... diff --git a/pytype/tools/analyze_project/pytype_runner_test.py b/pytype/tools/analyze_project/pytype_runner_test.py index e21b21dbe..3c7f5e9f5 100644 --- a/pytype/tools/analyze_project/pytype_runner_test.py +++ b/pytype/tools/analyze_project/pytype_runner_test.py @@ -232,7 +232,7 @@ def setUp(self): def assertFlags(self, flags, expected_flags): # Add temporary flags that are set to true by default here, so that they are # filtered out of tests. - temporary_flags = {'--use-enum-overlay'} + temporary_flags = set() self.assertEqual(flags - temporary_flags, expected_flags) # --disable tests a flag with a string value.