Skip to content

Commit

Permalink
Declare instance vars w/ annotations in class body
Browse files Browse the repository at this point in the history
  • Loading branch information
mike8699 committed Sep 21, 2023
1 parent 0c3c468 commit d596179
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions ndspy/bmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import os
import struct
from typing import Literal

from . import _common

Expand All @@ -36,13 +37,24 @@ class BMG:
"""
A class representing a BMG file.
"""
messages: list[Message]
instructions: list[bytes]
labels: list[tuple[int, int]]
scripts: list[tuple[int, int]]

id: int
encoding: str
endianness: Literal['<', '>']
unk14: int
unk18: int
unk1C: int

def __init__(self, data: bytes | None = None, *, id: int = 0):

self.messages: list[Message] = []
self.instructions: list[bytes] = []
self.labels: list[tuple[int, int]] = []
self.scripts: list[tuple[int, int]] = []
self.messages = []
self.instructions = []
self.labels = []
self.scripts = []

self.id = id

Expand Down Expand Up @@ -373,6 +385,9 @@ class Escape:
type and optional parameter data.
"""

type: int
data: bytes

def __init__(self, type: int = 0, data: bytes = b''):
self.type = type
self.data = data
Expand All @@ -398,9 +413,9 @@ def __repr__(self) -> str:
def __str__(self) -> str:
return f'[{self.type}:{self.data.hex()}]'

info: int = 0
stringParts: list[str] | None = None
isNull: bool = False
info: bytes
stringParts: list[str]
isNull: bool

def __init__(
self,
Expand Down

0 comments on commit d596179

Please sign in to comment.