Skip to content

Commit d7bfa6f

Browse files
committed
ClassIsAndAttribute and DOT matchcase for python version guard
1 parent 638c1c2 commit d7bfa6f

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

astToolkit/_toolClassIsAndAttribute.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: reportMatchNotExhaustive=false
12
# pyright: reportArgumentType=false
23
"""This file is generated automatically, so changes to this file will be lost."""
34
from astToolkit import (
@@ -206,14 +207,15 @@ def decorator_listIs(astClass: type[hasDOTdecorator_list], attributeCondition: C
206207
def workhorse(node: ast.AST) -> TypeGuard[hasDOTdecorator_list] | bool:
207208
return isinstance(node, astClass) and attributeCondition(node.decorator_list)
208209
return workhorse
209-
if sys.version_info >= (3, 13):
210+
match sys.version_info:
211+
case version if version >= (3, 13):
210212

211-
@staticmethod
212-
def default_valueIs(astClass: type[hasDOTdefault_value], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTdefault_value] | bool]:
213+
@staticmethod
214+
def default_valueIs(astClass: type[hasDOTdefault_value], attributeCondition: Callable[[ast.expr], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTdefault_value] | bool]:
213215

214-
def workhorse(node: ast.AST) -> TypeGuard[hasDOTdefault_value] | bool:
215-
return isinstance(node, astClass) and node.default_value is not None and attributeCondition(node.default_value)
216-
return workhorse
216+
def workhorse(node: ast.AST) -> TypeGuard[hasDOTdefault_value] | bool:
217+
return isinstance(node, astClass) and node.default_value is not None and attributeCondition(node.default_value)
218+
return workhorse
217219

218220
@staticmethod
219221
def defaultsIs(astClass: type[hasDOTdefaults], attributeCondition: Callable[[Sequence[ast.expr]], bool]) -> Callable[[ast.AST], TypeGuard[hasDOTdefaults] | bool]:

astToolkit/_toolDOT.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# pyright: reportReturnType=false
2+
# pyright: reportMatchNotExhaustive=false
23
"""This file is generated automatically, so changes to this file will be lost."""
34
from astToolkit import (
45
ConstantValueType, hasDOTannotation, hasDOTannotation_expr, hasDOTannotation_exprOrNone, hasDOTarg,
@@ -152,11 +153,12 @@ def ctx(node: hasDOTctx) -> ast.expr_context:
152153
@staticmethod
153154
def decorator_list(node: hasDOTdecorator_list) -> Sequence[ast.expr]:
154155
return node.decorator_list
155-
if sys.version_info >= (3, 13):
156+
match sys.version_info:
157+
case version if version >= (3, 13):
156158

157-
@staticmethod
158-
def default_value(node: hasDOTdefault_value) -> ast.expr:
159-
return node.default_value
159+
@staticmethod
160+
def default_value(node: hasDOTdefault_value) -> ast.expr:
161+
return node.default_value
160162

161163
@staticmethod
162164
def defaults(node: hasDOTdefaults) -> Sequence[ast.expr]:

0 commit comments

Comments
 (0)