File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 11# Change Log
22
3+ ## Unreleased
4+
5+ Bugfixes:
6+ * Fix Y026 false positive: allow simple assignment to ` None ` in class scopes
7+ if the class is known to be an enum class.
8+
39## 24.3.1
410
511New error codes:
Original file line number Diff line number Diff line change @@ -1219,7 +1219,7 @@ def _check_for_type_aliases(
12191219 isinstance (assignment , ast .Subscript )
12201220 or _is_valid_pep_604_union (assignment )
12211221 or _is_Any (assignment )
1222- or _is_None (assignment )
1222+ or ( _is_None (assignment ) and not self . visiting_enum_class )
12231223 ):
12241224 new_node = ast .AnnAssign (
12251225 target = target ,
Original file line number Diff line number Diff line change 22import array
33import builtins
44import collections .abc
5+ import enum
56import typing
67from collections .abc import Mapping
78from typing import (
@@ -86,3 +87,6 @@ _snake_case_alias2: TypeAlias = Literal["whatever"] # Y042 Type aliases should
8687
8788# check that this edge case doesn't crash the plugin
8889_ : TypeAlias = str | int
90+
91+ class FooEnum (enum .Enum ):
92+ BAR = None # shouldn't emit Y026 because it's an assignment in an enum class
You can’t perform that action at this time.
0 commit comments