Skip to content
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

Google sync #1537

Merged
merged 2 commits into from
Nov 30, 2023
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
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
16 changes: 7 additions & 9 deletions docs/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ of pytype.
* [Third-Party Libraries](#third-party-libraries)

<!-- Created by https://github.com/ekalinin/github-markdown-toc -->
<!-- Added by: rechen, at: Fri Nov 3 11:19:00 AM PDT 2023 -->
<!-- Added by: rechen, at: Tue Nov 28 03:37:40 PM PST 2023 -->

<!--te-->

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pytype/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# pylint: skip-file
__version__ = '2023.11.21'
__version__ = '2023.11.29'
2 changes: 1 addition & 1 deletion pytype/abstract/_special_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions pytype/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pytype/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
21 changes: 9 additions & 12 deletions pytype/overlays/enum_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down
1 change: 0 additions & 1 deletion pytype/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
3 changes: 1 addition & 2 deletions pytype/tests/test_pyi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down
2 changes: 1 addition & 1 deletion pytype/tools/analyze_project/pytype_runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading