Skip to content

Commit 0674535

Browse files
authored
Merge pull request #661 from boriel/refact/refact_code
refact: move code from backend.__init__.py to files
2 parents d81fa85 + cde868d commit 0674535

25 files changed

Lines changed: 1146 additions & 1138 deletions

File tree

src/api/global_.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
# This program is Free Software and is released under the terms of
99
# the GNU General License
1010
# ----------------------------------------------------------------------
11-
from typing import Dict, List, NamedTuple, Optional, Set, Final
11+
from typing import Dict, Final, List, NamedTuple, Optional, Set
1212

1313
from src.api.constants import TYPE, LoopType
1414
from src.api.opcodestemps import OpcodesTemps
1515

16-
1716
# ----------------------------------------------------------------------
1817
# Simple global container for internal constants.
1918
# Internal constants might be architecture dependant. They're set
@@ -116,9 +115,9 @@ class LoopInfo(NamedTuple):
116115
BOUND_TYPE = None # Set to None, so if not set will raise error
117116

118117
# ----------------------------------------------------------------------
119-
# Data type used for elements size. Must be an integral
118+
# Data type used for elements size. Must be an integral type
120119
# ----------------------------------------------------------------------
121-
SIZE_TYPE: Final[TYPE] = TYPE.ubyte
120+
SIZE_TYPE: TYPE = TYPE.ubyte
122121

123122
# ----------------------------------------------------------------------
124123
# CORE namespace (for core runtime library, like FP Calc)
@@ -145,7 +144,7 @@ class LoopInfo(NamedTuple):
145144
# ----------------------------------------------------------------------
146145
# Data Type used for string chars index. Must be an integral
147146
# ----------------------------------------------------------------------
148-
STR_INDEX_TYPE: Final[TYPE] = TYPE.uinteger
147+
STR_INDEX_TYPE: TYPE = TYPE.uinteger
149148

150149
# ----------------------------------------------------------------------
151150
# MIN and MAX str slice index

src/api/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def first(iter_: Iterable[T], default: T | None = None) -> T | None:
3434
return next(iter(iter_), default)
3535

3636

37+
def sfirst(iter_: Iterable[T]) -> T:
38+
"""Return the first element of an Iterable, or fails if it's empty"""
39+
return next(iter(iter_))
40+
41+
3742
def read_txt_file(fname: str) -> str:
3843
"""Reads a txt file, regardless of its encoding"""
3944
encodings = ["utf-8-sig", "cp1252"]

src/arch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
import importlib
66

7-
__all__ = [
7+
__all__ = (
88
"zx48k",
99
"zxnext",
10-
]
10+
)
1111

1212
AVAILABLE_ARCHITECTURES = __all__
1313
target = None

0 commit comments

Comments
 (0)