MCPcopy Index your code
hub / github.com/python/cpython / __post_init__

Method __post_init__

Tools/clinic/libclinic/codegen.py:225–248  ·  view source on GitHub ↗
(self, args: tuple[str, ...])

Source from the content-addressed store, hash-verified

223 args: dc.InitVar[tuple[str, ...]] = ()
224
225 def __post_init__(self, args: tuple[str, ...]) -> None:
226 valid_types = ('buffer', 'file', 'suppress')
227 if self.type not in valid_types:
228 fail(
229 f"Invalid destination type {self.type!r} for {self.name}, "
230 f"must be {', '.join(valid_types)}"
231 )
232 extra_arguments = 1 if self.type == "file" else 0
233 if len(args) < extra_arguments:
234 fail(f"Not enough arguments for destination "
235 f"{self.name!r} new {self.type!r}")
236 if len(args) > extra_arguments:
237 fail(f"Too many arguments for destination {self.name!r} new {self.type!r}")
238 if self.type =='file':
239 d = {}
240 filename = self.clinic.filename
241 d['path'] = filename
242 dirname, basename = os.path.split(filename)
243 if not dirname:
244 dirname = '.'
245 d['dirname'] = dirname
246 d['basename'] = basename
247 d['basename_root'], d['basename_extension'] = os.path.splitext(filename)
248 self.filename = args[0].format_map(d)
249
250 def __repr__(self) -> str:
251 if self.type == 'file':

Callers

nothing calls this directly

Calls 5

failFunction · 0.90
splitextMethod · 0.80
format_mapMethod · 0.80
joinMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected