Fix several issues revealed by testing and static analysis

- Fix type annotations in d2warehouse.stash
- Fix invalid escape sequences in d2warehouse.item
- Bump the minimum supported version of python to 3.10
- Fix ambiguous variable name in d2warehouse.huffman
This commit is contained in:
2023-10-24 01:29:58 +02:00
parent 223c8edf1c
commit 4a57291ba0
4 changed files with 6 additions and 6 deletions

View File

@@ -62,9 +62,9 @@ decode_tree = decodetree(code)
def decode(bits: bitarray, n) -> tuple[str, int]: def decode(bits: bitarray, n) -> tuple[str, int]:
s = "".join(itertools.islice(bits.iterdecode(decode_tree), n)) text = "".join(itertools.islice(bits.iterdecode(decode_tree), n))
l = len(encode(s)) length = len(encode(text))
return s, l return text, length
def encode(s: str) -> bitarray: def encode(s: str) -> bitarray:

View File

@@ -62,7 +62,7 @@ class Stat:
for val in self.values: for val in self.values:
subst_text = subst_text.replace("#", str(val), 1) subst_text = subst_text.replace("#", str(val), 1)
if self.parameter: if self.parameter:
subst_text = re.sub("\[[^\]]*\]", str(self.parameter), subst_text, 1) subst_text = re.sub(r"\[[^\]]*\]", str(self.parameter), subst_text, 1)
print(" " * indent, subst_text) print(" " * indent, subst_text)

View File

@@ -14,7 +14,7 @@
# #
# You should have received a copy of the GNU General Public License along with # You should have received a copy of the GNU General Public License along with
# Mercator. If not, see <https://www.gnu.org/licenses/>. # Mercator. If not, see <https://www.gnu.org/licenses/>.
from bitarray import bitarray from d2warehouse.item import Item
class Stash: class Stash:

View File

@@ -14,7 +14,7 @@ classifiers = [
"Environment :: Console", "Environment :: Console",
] ]
requires-python = ">=3.9" requires-python = ">=3.10"
license = {text = "GPLv3 License"} license = {text = "GPLv3 License"}
dependencies = [ dependencies = [
"bitarray", "bitarray",