tokenizers icon indicating copy to clipboard operation
tokenizers copied to clipboard

[FR] Add type hint for python

Open zhaob1n opened this issue 10 months ago • 4 comments

Could you please add type hint support for python bindings, even ?

my language server(basedpyright) complains everywhere tokenziers package is used

Image
/home/ykpcx/euclid/main.py
  /home/ykpcx/euclid/main.py:7:1 - error: Type of "tokenizer" is unknown (reportUnknownVariableType)
  /home/ykpcx/euclid/main.py:7:13 - error: Type of "from_str" is partially unknown
    Type of "from_str" is "(json: Unknown) -> Unknown" (reportUnknownMemberType)
  /home/ykpcx/euclid/main.py:10:5 - error: Type of "output" is unknown (reportUnknownVariableType)
  /home/ykpcx/euclid/main.py:10:14 - error: Type of "encode_batch" is unknown (reportUnknownMemberType)
  /home/ykpcx/euclid/main.py:11:15 - error: Type of "ids" is unknown (reportUnknownMemberType)
  /home/ykpcx/euclid/main.py:11:15 - error: Argument type is unknown
    Argument corresponds to parameter "obj" in function "len" (reportUnknownArgumentType)
  /home/ykpcx/euclid/main.py:12:11 - error: Type of "tokens" is unknown (reportUnknownMemberType)
  /home/ykpcx/euclid/main.py:12:11 - error: Argument type is unknown
    Argument corresponds to parameter "values" in function "print" (reportUnknownArgumentType)
8 errors, 0 warnings, 0 notes

zhaob1n avatar Jan 11 '26 04:01 zhaob1n

Hey! Pretty sure they were added in 0.22.2! Can you make sure you have that version? EDIT: actually we added type check but maybe not type hint!

ArthurZucker avatar Jan 12 '26 09:01 ArthurZucker

Hey! Pretty sure they were added in 0.22.2! Can you make sure you have that version? EDIT: actually we added type check but maybe not type hint!

I am sure I am using 0.22.2, there is no type hints.

zhaob1n avatar Jan 12 '26 09:01 zhaob1n

Yeah I'll work on that, its a bit experimental TBH https://pyo3.rs/v0.27.1/python-typing-hints is a bit new

ArthurZucker avatar Jan 12 '26 11:01 ArthurZucker

Closed in #1928

ArthurZucker avatar Feb 16 '26 09:02 ArthurZucker