I need to ignore pyright checking for one line. Is there any special comment for it?
def create_slog(group: SLogGroup, data: Optional[dict] = None):
SLog.insert_one(SLog(group=group, data=data)) # pyright: disable
# pyright: disable
-- doesn't work
Yes it is with "# type: ignore", for example:
try:
return int(maybe_digits_string) # type: ignore
except Exception:
return None
As mentioned in the accepted answer's comments, using # type: ignore
is effective but it collides with other type checkers (such as mypy).
Pyright now supports # pyright: ignore
comments. This is documented here.
foo: int = "123" # pyright: ignore
This comment can be followed by a comma-delimited list of pyright rules that should be ignored:
foo: int = "123" # pyright: ignore [reportPrivateUsage, reportGeneralTypeIssues]
Meanwhile, adding the following comment to the top level of your module will disable checking of the listed rules for the whole file:
# pyright: reportUndefinedVariable=false, reportGeneralTypeIssues=false
See the pyright docs on comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With