Skip to content

Commit b80bbef

Browse files
committed
Fix mypy errors in CI: remove unsupported python_version, add types-regex, fix type annotations
- Remove python_version=3.9 from mypy config (no longer supported) - Install regex and types-regex in lint CI for proper type checking - Update bpe.pyi Trainer.__init__ to accept list[bytes | bytearray] - Add explicit type annotation in simple.py for text_bytes_list
1 parent 9821993 commit b80bbef

4 files changed

Lines changed: 3 additions & 4 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install dependencies
2525
run: |
2626
python -m pip install --upgrade pip
27-
python -m pip install ruff mypy
27+
python -m pip install ruff mypy regex types-regex
2828
- name: Run ruff (lint)
2929
run: ruff check tinybpe/ --output-format=github
3030
- name: Run ruff (format check)

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ indent-style = "space"
5555

5656
[tool.mypy]
5757
strict = true
58-
python_version = "3.9"
5958

6059
[tool.pytest.ini_options]
6160
testpaths = ["tests"]

tinybpe/bpe.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Tokenizer:
2222
class Trainer:
2323
"""This is a BPE trainer implemented in C ."""
2424

25-
def __init__(self, list_bytes: list[bytes]): ...
25+
def __init__(self, list_bytes: list[bytes | bytearray]): ...
2626
@property
2727
def n_merges(self) -> int: ...
2828
@property

tinybpe/simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
callback: Callable[[int, int, tuple[int, int], int, int], None] | None = None,
6363
) -> None:
6464
if preprocess is None:
65-
text_bytes_list = [text.encode("utf-8")]
65+
text_bytes_list: list[bytes | bytearray] = [text.encode("utf-8")]
6666
else:
6767
text_bytes_list = preprocess(text)
6868

0 commit comments

Comments
 (0)