Skip to content

Commit 6b5bcc6

Browse files
committed
Replace pyright with ty
1 parent bbf5886 commit 6b5bcc6

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ repos:
1616
- id: ruff-check
1717
- id: ruff-format
1818

19-
- repo: https://github.com/RobertCraigie/pyright-python
20-
rev: v1.1.406
19+
- repo: local
2120
hooks:
22-
- id: pyright
21+
- id: ty-check
22+
name: ty check
23+
description: Type check with ty.
24+
entry: uvx ty check
25+
language: system
26+
pass_filenames: false
27+
require_serial: true

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dev = [
3333
"pytest-cov~=7.0.0",
3434
"pytest~=8.4.2",
3535
"setuptools>=61",
36+
"ty>=0.0.2",
3637
]
3738

3839
[tool.setuptools]
@@ -55,7 +56,5 @@ ignore = ["A", "D", "T"]
5556
[tool.ruff.lint.per-file-ignores]
5657
"**/tests/*" = ["S101", "S603"]
5758

58-
[tool.pyright]
59-
venvPath = "."
60-
venv = ".venv"
59+
[tool.ty.src]
6160
exclude = ["tests/code/**"]

src/no_code/no.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ def nothing(data: str, /) -> str: ...
2424
def nothing(data: "ReadableBuffer", /, *, errors: str = "strict") -> bytes: ...
2525
def nothing(data: "str | ReadableBuffer", /, *, errors: str = "strict") -> str | bytes:
2626
"""Transform a string or bytes-like object into nothing."""
27-
as_string = isinstance(data, str)
28-
data_bytes = data.encode("utf-8", errors) if as_string else bytes(data)
27+
data_bytes = data.encode("utf-8", errors) if isinstance(data, str) else bytes(data)
2928
transformed = "".join(format(byte, "08b") for byte in data_bytes).translate({48: 0x200B, 49: 0x200C})
30-
return transformed if as_string else transformed.encode("utf-8", errors)
29+
return transformed if isinstance(data, str) else transformed.encode("utf-8", errors)
3130

3231

3332
@overload
@@ -36,8 +35,7 @@ def something(data: str, /) -> str: ...
3635
def something(data: "ReadableBuffer", /, *, errors: str = "strict") -> bytes: ...
3736
def something(data: "str | ReadableBuffer", /, *, errors: str = "strict") -> str | bytes:
3837
"""Transform nothing into a string or bytes-like object."""
39-
as_string = isinstance(data, str)
40-
data_str = data if as_string else bytes(data).decode("utf-8", errors)
38+
data_str = data if isinstance(data, str) else bytes(data).decode("utf-8", errors)
4139
chars = bytearray()
4240
bits = []
4341
for char in data_str:
@@ -50,7 +48,7 @@ def something(data: "str | ReadableBuffer", /, *, errors: str = "strict") -> str
5048
if len(bits) == BYTE_SIZE:
5149
chars.append(int("".join(bits), base=2))
5250
bits.clear()
53-
return chars.decode("utf-8", errors) if as_string else bytes(chars)
51+
return chars.decode("utf-8", errors) if isinstance(data, str) else bytes(chars)
5452

5553

5654
def encode(input: str, errors: str | None = None, /) -> tuple[bytes, int]:

uv.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)