Use correct default type for str (#8623)

* [Python] Use correct type for str with None

Otherwise mypy will correctly flag code like this

def __init__(self):
  self.fooBar = None  # type: Optional[str]

error: Incompatible types in assignment (expression has type "None", variable has type "str")

* [Python] Make list type optional as they can contain None
This commit is contained in:
Felix
2025-07-05 01:47:36 +02:00
committed by GitHub
parent 6b251aa1cf
commit c15fe421ba
9 changed files with 61 additions and 61 deletions

View File

@@ -116,11 +116,11 @@ class ArrayStructT(object):
# ArrayStructT
def __init__(self):
self.a = 0.0 # type: float
self.b = None # type: List[int]
self.b = None # type: Optional[List[int]]
self.c = 0 # type: int
self.d = None # type: List[MyGame.Example.NestedStruct.NestedStructT]
self.d = None # type: Optional[List[MyGame.Example.NestedStruct.NestedStructT]]
self.e = 0 # type: int
self.f = None # type: List[int]
self.f = None # type: Optional[List[int]]
@classmethod
def InitFromBuf(cls, buf, pos):