PyDocs

Nav

Python Language Services

TypeIgnore

ast

class · Added in 3.8
  • TypeIgnore(lineno, tag)
TypeIgnore(int lineno, string tag)
1 Example
>>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), indent=4))
Module(
    body=[
        Assign(
            targets=[
                Name(id='x', ctx=Store())],
            value=Constant(value=1))],
    type_ignores=[
        TypeIgnore(lineno=1, tag='')])
>>> print(ast.dump(ast.parse('x: bool = 1 # type: ignore[assignment]', type_comments=True), indent=4))
Module(
    body=[
        AnnAssign(
            target=Name(id='x', ctx=Store()),
            annotation=Name(id='bool'),
            value=Constant(value=1),
            simple=1)],
    type_ignores=[
        TypeIgnore(lineno=1, tag='[assignment]')])
from the Python docs
See Also
No see-alsos for ast/TypeIgnore
0 Notes
No notes for TypeIgnore