Skip to content

Commit c27d432

Browse files
elmcresttomasr8
andauthored
Fix type hints and formatting (#4)
* fix type hints and formatting * Remove `noqa: ...` --------- Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
1 parent 5468c6b commit c27d432

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

pyjsx/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55

66
__version__ = "0.1.0"
7-
__all__ = ["register_jsx", "transpile", "jsx", "JSX", "JSXComponent"]
7+
__all__ = ["JSX", "JSXComponent", "jsx", "register_jsx", "transpile"]

pyjsx/codecs.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
from __future__ import annotations
2+
13
import codecs
24
import encodings
5+
from typing import TYPE_CHECKING
6+
7+
8+
if TYPE_CHECKING:
9+
from _typeshed import ReadableBuffer
310

411
from pyjsx.transpiler import transpile
512

613

7-
def pyjsx_decode(input: memoryview, errors: str = "strict") -> tuple[str, int]: # noqa: A002, ARG001
8-
return transpile(bytes(input).decode("utf-8")), len(input)
14+
def pyjsx_decode(input: ReadableBuffer, errors: str = "strict") -> tuple[str, int]: # noqa: A002, ARG001
15+
byte_content = bytes(input)
16+
return transpile(byte_content.decode("utf-8")), len(byte_content)
917

1018

1119
def pyjsx_search_function(encoding: str) -> codecs.CodecInfo | None:

pyjsx/jsx.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import sys
43
from typing import Any, Protocol, TypeAlias
54

65
from pyjsx.elements import is_void_element

pyjsx/tokenizer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def tokenize_jsx(self) -> Generator[Token, None, None]: # noqa: C901, PLR0912,
216216
yield Token(TokenType.JSX_TEXT, text, self.curr, self.curr + len(text))
217217
self.curr += len(text)
218218
else:
219-
msg = f"Unexpected token {self.source[self.curr:]}"
219+
msg = f"Unexpected token {self.source[self.curr :]}"
220220
raise TokenizerError(msg)
221221

222222
def tokenize_py(self) -> Generator[Token, None, None]: # noqa: C901, PLR0912, PLR0915
@@ -386,6 +386,6 @@ def tokenize_fstring(self) -> Generator[Token, None, None]:
386386
else:
387387
break
388388
if not middle:
389-
msg = f"Unexpected token {self.source[self.curr:]}"
389+
msg = f"Unexpected token {self.source[self.curr :]}"
390390
raise TokenizerError(msg)
391391
yield Token(TokenType.FSTRING_MIDDLE, middle, self.curr, self.curr + len(middle))

0 commit comments

Comments
 (0)