Tell mypy about the values of name in nodes

master
Salvo 'LtWorf' Tomaselli 2020-06-14 22:43:50 +07:00
parent 4ab01c9e47
commit c5a71be509
No known key found for this signature in database
GPG Key ID: B3A7CF0C801886CF
1 changed files with 8 additions and 1 deletions

@ -24,7 +24,7 @@
#
# Language definition here:
# http://ltworf.github.io/relational/grammar.html
from typing import Optional, Union, List, Any, Dict
from typing import Optional, Union, List, Any, Dict, Literal
from dataclasses import dataclass
from relational import rtypes
@ -43,6 +43,11 @@ SELECTION = 'σ'
RENAME = 'ρ'
ARROW = ''
BINARY_LITERALS_T = Literal['*', '-', '', '', '÷', '', '', '', '']
UNARY_LITERALS_T = Literal['π', 'σ', 'ρ']
b_operators = (PRODUCT, DIFFERENCE, UNION, INTERSECTION, DIVISION,
JOIN, JOIN_LEFT, JOIN_RIGHT, JOIN_FULL) # List of binary operators
u_operators = (PROJECTION, SELECTION, RENAME) # List of unary operators
@ -194,6 +199,7 @@ class Variable(Node):
@dataclass
class Binary(Node):
name: BINARY_LITERALS_T
left: Node
right: Node
@ -214,6 +220,7 @@ class Binary(Node):
@dataclass
class Unary(Node):
name: UNARY_LITERALS_T
prop: str
child: Node