MCPcopy Index your code
hub / github.com/RustPython/RustPython / __init__

Method __init__

Lib/tomllib/_parser.py:74–121  ·  view source on GitHub ↗
(
        self,
        msg: str = DEPRECATED_DEFAULT,  # type: ignore[assignment]
        doc: str = DEPRECATED_DEFAULT,  # type: ignore[assignment]
        pos: Pos = DEPRECATED_DEFAULT,  # type: ignore[assignment]
        *args: Any,
    )

Source from the content-addressed store, hash-verified

72 """
73
74 def __init__(
75 self,
76 msg: str = DEPRECATED_DEFAULT, # type: ignore[assignment]
77 doc: str = DEPRECATED_DEFAULT, # type: ignore[assignment]
78 pos: Pos = DEPRECATED_DEFAULT, # type: ignore[assignment]
79 *args: Any,
80 ):
81 if (
82 args
83 or not isinstance(msg, str)
84 or not isinstance(doc, str)
85 or not isinstance(pos, int)
86 ):
87 import warnings
88
89 warnings.warn(
90 "Free-form arguments for TOMLDecodeError are deprecated. "
91 "Please set 'msg' (str), 'doc' (str) and 'pos' (int) arguments only.",
92 DeprecationWarning,
93 stacklevel=2,
94 )
95 if pos is not DEPRECATED_DEFAULT: # type: ignore[comparison-overlap]
96 args = pos, *args
97 if doc is not DEPRECATED_DEFAULT: # type: ignore[comparison-overlap]
98 args = doc, *args
99 if msg is not DEPRECATED_DEFAULT: # type: ignore[comparison-overlap]
100 args = msg, *args
101 ValueError.__init__(self, *args)
102 return
103
104 lineno = doc.count("\n", 0, pos) + 1
105 if lineno == 1:
106 colno = pos + 1
107 else:
108 colno = pos - doc.rindex("\n", 0, pos)
109
110 if pos >= len(doc):
111 coord_repr = "end of document"
112 else:
113 coord_repr = f"line {lineno}, column {colno}"
114 errmsg = f"{msg} (at {coord_repr})"
115 ValueError.__init__(self, errmsg)
116
117 self.msg = msg
118 self.doc = doc
119 self.pos = pos
120 self.lineno = lineno
121 self.colno = colno
122
123
124def load(fp: IO[bytes], /, *, parse_float: ParseFloat = float) -> dict[str, Any]:

Callers

nothing calls this directly

Calls 6

isinstanceFunction · 0.85
lenFunction · 0.85
warnMethod · 0.45
__init__Method · 0.45
countMethod · 0.45
rindexMethod · 0.45

Tested by

no test coverage detected