Skip to content

Commit c4b8f62

Browse files
committed
DOT can return None or Sequence[None]
1 parent c0b4996 commit c4b8f62

2 files changed

Lines changed: 53 additions & 54 deletions

File tree

astToolkit/_toolBe.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ def BitOr(node: ast.AST) -> TypeIs[ast.BitOr]:
132132
def BitXor(node: ast.AST) -> TypeIs[ast.BitXor]:
133133
return isinstance(node, ast.BitXor)
134134

135-
@staticmethod
136-
def BoolOp(node: ast.AST) -> TypeIs[ast.BoolOp]:
137-
return isinstance(node, ast.BoolOp)
138-
139135
@staticmethod
140136
def boolop(node: ast.AST) -> TypeIs[ast.boolop]:
141137
return isinstance(node, ast.boolop)
142138

139+
@staticmethod
140+
def BoolOp(node: ast.AST) -> TypeIs[ast.BoolOp]:
141+
return isinstance(node, ast.BoolOp)
142+
143143
@staticmethod
144144
def Break(node: ast.AST) -> TypeIs[ast.Break]:
145145
return isinstance(node, ast.Break)
@@ -196,22 +196,22 @@ def Div(node: ast.AST) -> TypeIs[ast.Div]:
196196
def Eq(node: ast.AST) -> TypeIs[ast.Eq]:
197197
return isinstance(node, ast.Eq)
198198

199-
@staticmethod
200-
def ExceptHandler(node: ast.AST) -> TypeIs[ast.ExceptHandler]:
201-
return isinstance(node, ast.ExceptHandler)
202-
203199
@staticmethod
204200
def excepthandler(node: ast.AST) -> TypeIs[ast.excepthandler]:
205201
return isinstance(node, ast.excepthandler)
206202

207203
@staticmethod
208-
def Expr(node: ast.AST) -> TypeIs[ast.Expr]:
209-
return isinstance(node, ast.Expr)
204+
def ExceptHandler(node: ast.AST) -> TypeIs[ast.ExceptHandler]:
205+
return isinstance(node, ast.ExceptHandler)
210206

211207
@staticmethod
212208
def expr(node: ast.AST) -> TypeIs[ast.expr]:
213209
return isinstance(node, ast.expr)
214210

211+
@staticmethod
212+
def Expr(node: ast.AST) -> TypeIs[ast.Expr]:
213+
return isinstance(node, ast.Expr)
214+
215215
@staticmethod
216216
def expr_context(node: ast.AST) -> TypeIs[ast.expr_context]:
217217
return isinstance(node, ast.expr_context)
@@ -372,14 +372,14 @@ def MatchValue(node: ast.AST) -> TypeIs[ast.MatchValue]:
372372
def MatMult(node: ast.AST) -> TypeIs[ast.MatMult]:
373373
return isinstance(node, ast.MatMult)
374374

375-
@staticmethod
376-
def Mod(node: ast.AST) -> TypeIs[ast.Mod]:
377-
return isinstance(node, ast.Mod)
378-
379375
@staticmethod
380376
def mod(node: ast.AST) -> TypeIs[ast.mod]:
381377
return isinstance(node, ast.mod)
382378

379+
@staticmethod
380+
def Mod(node: ast.AST) -> TypeIs[ast.Mod]:
381+
return isinstance(node, ast.Mod)
382+
383383
@staticmethod
384384
def Module(node: ast.AST) -> TypeIs[ast.Module]:
385385
return isinstance(node, ast.Module)
@@ -520,14 +520,14 @@ def TypeVarTuple(node: ast.AST) -> TypeIs[ast.TypeVarTuple]:
520520
def UAdd(node: ast.AST) -> TypeIs[ast.UAdd]:
521521
return isinstance(node, ast.UAdd)
522522

523-
@staticmethod
524-
def UnaryOp(node: ast.AST) -> TypeIs[ast.UnaryOp]:
525-
return isinstance(node, ast.UnaryOp)
526-
527523
@staticmethod
528524
def unaryop(node: ast.AST) -> TypeIs[ast.unaryop]:
529525
return isinstance(node, ast.unaryop)
530526

527+
@staticmethod
528+
def UnaryOp(node: ast.AST) -> TypeIs[ast.UnaryOp]:
529+
return isinstance(node, ast.UnaryOp)
530+
531531
@staticmethod
532532
def USub(node: ast.AST) -> TypeIs[ast.USub]:
533533
return isinstance(node, ast.USub)

astToolkit/_toolDOT.py

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pyright: reportReturnType=false
21
# pyright: reportMatchNotExhaustive=false
32
"""This file is generated automatically, so changes to this file will be lost."""
43
from astToolkit import (
@@ -51,11 +50,11 @@ def annotation(node: hasDOTannotation_expr) -> ast.expr:
5150

5251
@staticmethod
5352
@overload
54-
def annotation(node: hasDOTannotation_exprOrNone) -> ast.expr:
53+
def annotation(node: hasDOTannotation_exprOrNone) -> ast.expr | None:
5554
...
5655

5756
@staticmethod
58-
def annotation(node: hasDOTannotation) -> ast.expr:
57+
def annotation(node: hasDOTannotation) -> ast.expr | (ast.expr | None):
5958
return node.annotation
6059

6160
@staticmethod
@@ -65,11 +64,11 @@ def arg(node: hasDOTarg_str) -> str:
6564

6665
@staticmethod
6766
@overload
68-
def arg(node: hasDOTarg_strOrNone) -> str:
67+
def arg(node: hasDOTarg_strOrNone) -> str | None:
6968
...
7069

7170
@staticmethod
72-
def arg(node: hasDOTarg) -> str:
71+
def arg(node: hasDOTarg) -> str | (str | None):
7372
return node.arg
7473

7574
@staticmethod
@@ -96,7 +95,7 @@ def argtypes(node: hasDOTargtypes) -> Sequence[ast.expr]:
9695
return node.argtypes
9796

9897
@staticmethod
99-
def asname(node: hasDOTasname) -> str:
98+
def asname(node: hasDOTasname) -> str | None:
10099
return node.asname
101100

102101
@staticmethod
@@ -122,15 +121,15 @@ def body(node: hasDOTbody) -> ast.expr | Sequence[ast.stmt]:
122121
return node.body
123122

124123
@staticmethod
125-
def bound(node: hasDOTbound) -> ast.expr:
124+
def bound(node: hasDOTbound) -> ast.expr | None:
126125
return node.bound
127126

128127
@staticmethod
129128
def cases(node: hasDOTcases) -> Sequence[ast.match_case]:
130129
return node.cases
131130

132131
@staticmethod
133-
def cause(node: hasDOTcause) -> ast.expr:
132+
def cause(node: hasDOTcause) -> ast.expr | None:
134133
return node.cause
135134

136135
@staticmethod
@@ -160,7 +159,7 @@ def decorator_list(node: hasDOTdecorator_list) -> Sequence[ast.expr]:
160159
case version if version >= (3, 13):
161160

162161
@staticmethod
163-
def default_value(node: hasDOTdefault_value) -> ast.expr:
162+
def default_value(node: hasDOTdefault_value) -> ast.expr | None:
164163
return node.default_value
165164

166165
@staticmethod
@@ -176,15 +175,15 @@ def elts(node: hasDOTelts) -> Sequence[ast.expr]:
176175
return node.elts
177176

178177
@staticmethod
179-
def exc(node: hasDOTexc) -> ast.expr:
178+
def exc(node: hasDOTexc) -> ast.expr | None:
180179
return node.exc
181180

182181
@staticmethod
183182
def finalbody(node: hasDOTfinalbody) -> Sequence[ast.stmt]:
184183
return node.finalbody
185184

186185
@staticmethod
187-
def format_spec(node: hasDOTformat_spec) -> ast.expr:
186+
def format_spec(node: hasDOTformat_spec) -> ast.expr | None:
188187
return node.format_spec
189188

190189
@staticmethod
@@ -196,7 +195,7 @@ def generators(node: hasDOTgenerators) -> Sequence[ast.comprehension]:
196195
return node.generators
197196

198197
@staticmethod
199-
def guard(node: hasDOTguard) -> ast.expr:
198+
def guard(node: hasDOTguard) -> ast.expr | None:
200199
return node.guard
201200

202201
@staticmethod
@@ -234,27 +233,27 @@ def keys(node: hasDOTkeys_list_expr) -> Sequence[ast.expr]:
234233

235234
@staticmethod
236235
@overload
237-
def keys(node: hasDOTkeys_list_exprOrNone) -> Sequence[ast.expr]:
236+
def keys(node: hasDOTkeys_list_exprOrNone) -> Sequence[ast.expr | None]:
238237
...
239238

240239
@staticmethod
241-
def keys(node: hasDOTkeys) -> Sequence[ast.expr]:
240+
def keys(node: hasDOTkeys) -> Sequence[ast.expr | None] | Sequence[ast.expr]:
242241
return node.keys
243242

244243
@staticmethod
245244
def keywords(node: hasDOTkeywords) -> Sequence[ast.keyword]:
246245
return node.keywords
247246

248247
@staticmethod
249-
def kind(node: hasDOTkind) -> str:
248+
def kind(node: hasDOTkind) -> str | None:
250249
return node.kind
251250

252251
@staticmethod
253-
def kw_defaults(node: hasDOTkw_defaults) -> Sequence[ast.expr]:
252+
def kw_defaults(node: hasDOTkw_defaults) -> Sequence[ast.expr | None]:
254253
return node.kw_defaults
255254

256255
@staticmethod
257-
def kwarg(node: hasDOTkwarg) -> ast.arg:
256+
def kwarg(node: hasDOTkwarg) -> ast.arg | None:
258257
return node.kwarg
259258

260259
@staticmethod
@@ -282,15 +281,15 @@ def lineno(node: hasDOTlineno) -> int:
282281
return node.lineno
283282

284283
@staticmethod
285-
def lower(node: hasDOTlower) -> ast.expr:
284+
def lower(node: hasDOTlower) -> ast.expr | None:
286285
return node.lower
287286

288287
@staticmethod
289-
def module(node: hasDOTmodule) -> str:
288+
def module(node: hasDOTmodule) -> str | None:
290289
return node.module
291290

292291
@staticmethod
293-
def msg(node: hasDOTmsg) -> ast.expr:
292+
def msg(node: hasDOTmsg) -> ast.expr | None:
294293
return node.msg
295294

296295
@staticmethod
@@ -305,11 +304,11 @@ def name(node: hasDOTname_str) -> str:
305304

306305
@staticmethod
307306
@overload
308-
def name(node: hasDOTname_strOrNone) -> str:
307+
def name(node: hasDOTname_strOrNone) -> str | None:
309308
...
310309

311310
@staticmethod
312-
def name(node: hasDOTname) -> ast.Name | str:
311+
def name(node: hasDOTname) -> ast.Name | str | (str | None):
313312
return node.name
314313

315314
@staticmethod
@@ -354,7 +353,7 @@ def ops(node: hasDOTops) -> Sequence[ast.cmpop]:
354353
return node.ops
355354

356355
@staticmethod
357-
def optional_vars(node: hasDOToptional_vars) -> ast.expr:
356+
def optional_vars(node: hasDOToptional_vars) -> ast.expr | None:
358357
return node.optional_vars
359358

360359
@staticmethod
@@ -378,11 +377,11 @@ def pattern(node: hasDOTpattern_pattern) -> ast.pattern:
378377

379378
@staticmethod
380379
@overload
381-
def pattern(node: hasDOTpattern_patternOrNone) -> ast.pattern:
380+
def pattern(node: hasDOTpattern_patternOrNone) -> ast.pattern | None:
382381
...
383382

384383
@staticmethod
385-
def pattern(node: hasDOTpattern) -> ast.pattern:
384+
def pattern(node: hasDOTpattern) -> ast.pattern | (ast.pattern | None):
386385
return node.pattern
387386

388387
@staticmethod
@@ -394,7 +393,7 @@ def posonlyargs(node: hasDOTposonlyargs) -> list[ast.arg]:
394393
return node.posonlyargs
395394

396395
@staticmethod
397-
def rest(node: hasDOTrest) -> str:
396+
def rest(node: hasDOTrest) -> str | None:
398397
return node.rest
399398

400399
@staticmethod
@@ -404,11 +403,11 @@ def returns(node: hasDOTreturns_expr) -> ast.expr:
404403

405404
@staticmethod
406405
@overload
407-
def returns(node: hasDOTreturns_exprOrNone) -> ast.expr:
406+
def returns(node: hasDOTreturns_exprOrNone) -> ast.expr | None:
408407
...
409408

410409
@staticmethod
411-
def returns(node: hasDOTreturns) -> ast.expr:
410+
def returns(node: hasDOTreturns) -> ast.expr | (ast.expr | None):
412411
return node.returns
413412

414413
@staticmethod
@@ -424,7 +423,7 @@ def slice(node: hasDOTslice) -> ast.expr:
424423
return node.slice
425424

426425
@staticmethod
427-
def step(node: hasDOTstep) -> ast.expr:
426+
def step(node: hasDOTstep) -> ast.expr | None:
428427
return node.step
429428

430429
@staticmethod
@@ -463,11 +462,11 @@ def test(node: hasDOTtest) -> ast.expr:
463462
return node.test
464463

465464
@staticmethod
466-
def type(node: hasDOTtype) -> ast.expr:
465+
def type(node: hasDOTtype) -> ast.expr | None:
467466
return node.type
468467

469468
@staticmethod
470-
def type_comment(node: hasDOTtype_comment) -> str:
469+
def type_comment(node: hasDOTtype_comment) -> str | None:
471470
return node.type_comment
472471

473472
@staticmethod
@@ -479,12 +478,12 @@ def type_params(node: hasDOTtype_params) -> Sequence[ast.type_param]:
479478
return node.type_params
480479

481480
@staticmethod
482-
def upper(node: hasDOTupper) -> ast.expr:
481+
def upper(node: hasDOTupper) -> ast.expr | None:
483482
return node.upper
484483

485484
@staticmethod
486485
@overload
487-
def value(node: hasDOTvalue_boolOrNone) -> bool:
486+
def value(node: hasDOTvalue_boolOrNone) -> bool | None:
488487
...
489488

490489
@staticmethod
@@ -499,17 +498,17 @@ def value(node: hasDOTvalue_expr) -> ast.expr:
499498

500499
@staticmethod
501500
@overload
502-
def value(node: hasDOTvalue_exprOrNone) -> ast.expr:
501+
def value(node: hasDOTvalue_exprOrNone) -> ast.expr | None:
503502
...
504503

505504
@staticmethod
506-
def value(node: hasDOTvalue) -> ast.expr | bool | ConstantValueType:
505+
def value(node: hasDOTvalue) -> ast.expr | (ast.expr | None) | (bool | None) | ConstantValueType:
507506
return node.value
508507

509508
@staticmethod
510509
def values(node: hasDOTvalues) -> Sequence[ast.expr]:
511510
return node.values
512511

513512
@staticmethod
514-
def vararg(node: hasDOTvararg) -> ast.arg:
513+
def vararg(node: hasDOTvararg) -> ast.arg | None:
515514
return node.vararg

0 commit comments

Comments
 (0)