MCPcopy Index your code
hub / github.com/python/mypy / Context

Class Context

mypy/nodes.py:89–126  ·  view source on GitHub ↗

Base type for objects that are valid as error message locations.

Source from the content-addressed store, hash-verified

87
88
89class Context:
90 """Base type for objects that are valid as error message locations."""
91
92 __slots__ = ("line", "column", "end_line", "end_column")
93
94 def __init__(self, line: int = -1, column: int = -1) -> None:
95 self.line = line
96 self.column = column
97 self.end_line: int | None = None
98 self.end_column: int | None = None
99
100 def set_line(
101 self,
102 target: Context | int,
103 column: int | None = None,
104 end_line: int | None = None,
105 end_column: int | None = None,
106 ) -> None:
107 """If target is a node, pull line (and column) information
108 into this node. If column is specified, this will override any column
109 information coming from a node.
110 """
111 if isinstance(target, int):
112 self.line = target
113 else:
114 self.line = target.line
115 self.column = target.column
116 self.end_line = target.end_line
117 self.end_column = target.end_column
118
119 if column is not None:
120 self.column = column
121
122 if end_line is not None:
123 self.end_line = end_line
124
125 if end_column is not None:
126 self.end_column = end_column
127
128
129if TYPE_CHECKING:

Callers 9

set_any_tvarsFunction · 0.90
find_memberFunction · 0.90
collect_attributesMethod · 0.90
deserializeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…