Assignment statement. The same node class is used for single assignment, multiple assignment (e.g. x, y = z) and chained assignment (e.g. x = y = z), assignments that define new names, and assignments with explicit types ("# type: t" or "x: t [= ...]"). An lvalue can be NameExp
| 1841 | |
| 1842 | |
| 1843 | class AssignmentStmt(Statement): |
| 1844 | """Assignment statement. |
| 1845 | |
| 1846 | The same node class is used for single assignment, multiple assignment |
| 1847 | (e.g. x, y = z) and chained assignment (e.g. x = y = z), assignments |
| 1848 | that define new names, and assignments with explicit types ("# type: t" |
| 1849 | or "x: t [= ...]"). |
| 1850 | |
| 1851 | An lvalue can be NameExpr, TupleExpr, ListExpr, MemberExpr, or IndexExpr. |
| 1852 | """ |
| 1853 | |
| 1854 | __slots__ = ( |
| 1855 | "lvalues", |
| 1856 | "rvalue", |
| 1857 | "type", |
| 1858 | "unanalyzed_type", |
| 1859 | "new_syntax", |
| 1860 | "is_alias_def", |
| 1861 | "is_final_def", |
| 1862 | "invalid_recursive_alias", |
| 1863 | ) |
| 1864 | |
| 1865 | __match_args__ = ("lvalues", "rvalues", "type") |
| 1866 | |
| 1867 | lvalues: list[Lvalue] |
| 1868 | # This is a TempNode if and only if no rvalue (x: t). |
| 1869 | rvalue: Expression |
| 1870 | # Declared type in a comment, may be None. |
| 1871 | type: mypy.types.Type | None |
| 1872 | # Original, not semantically analyzed type in annotation (used for reprocessing) |
| 1873 | unanalyzed_type: mypy.types.Type | None |
| 1874 | # This indicates usage of PEP 526 type annotation syntax in assignment. |
| 1875 | new_syntax: bool |
| 1876 | # Does this assignment define a type alias? |
| 1877 | is_alias_def: bool |
| 1878 | # Is this a final definition? |
| 1879 | # Final attributes can't be re-assigned once set, and can't be overridden |
| 1880 | # in a subclass. This flag is not set if an attempted declaration was found to |
| 1881 | # be invalid during semantic analysis. It is still set to `True` if |
| 1882 | # a final declaration overrides another final declaration (this is checked |
| 1883 | # during type checking when MROs are known). |
| 1884 | is_final_def: bool |
| 1885 | # Stop further processing of this assignment, to prevent flipping back and forth |
| 1886 | # during semantic analysis passes. |
| 1887 | invalid_recursive_alias: bool |
| 1888 | |
| 1889 | def __init__( |
| 1890 | self, |
| 1891 | lvalues: list[Lvalue], |
| 1892 | rvalue: Expression, |
| 1893 | type: mypy.types.Type | None = None, |
| 1894 | new_syntax: bool = False, |
| 1895 | ) -> None: |
| 1896 | super().__init__() |
| 1897 | self.lvalues = lvalues |
| 1898 | self.rvalue = rvalue |
| 1899 | self.type = type |
| 1900 | self.unanalyzed_type = type |
no outgoing calls
no test coverage detected
searching dependent graphs…