Add necessary dunder methods to classes decorated with attr.s. attrs is a package that lets you define classes without writing dull boilerplate code. At a quick glance, the decorator searches the class body for assignments of `attr.ib`s (or annotated variables if auto_attribs=True), th
(
ctx: mypy.plugin.ClassDefContext,
auto_attribs_default: bool | None = False,
frozen_default: bool = False,
slots_default: bool = False,
)
| 306 | |
| 307 | |
| 308 | def attr_class_maker_callback( |
| 309 | ctx: mypy.plugin.ClassDefContext, |
| 310 | auto_attribs_default: bool | None = False, |
| 311 | frozen_default: bool = False, |
| 312 | slots_default: bool = False, |
| 313 | ) -> bool: |
| 314 | """Add necessary dunder methods to classes decorated with attr.s. |
| 315 | |
| 316 | attrs is a package that lets you define classes without writing dull boilerplate code. |
| 317 | |
| 318 | At a quick glance, the decorator searches the class body for assignments of `attr.ib`s (or |
| 319 | annotated variables if auto_attribs=True), then depending on how the decorator is called, |
| 320 | it will add an __init__ or all the compare methods. |
| 321 | For frozen=True it will turn the attrs into properties. |
| 322 | |
| 323 | Hashability will be set according to https://www.attrs.org/en/stable/hashing.html. |
| 324 | |
| 325 | See https://www.attrs.org/en/stable/how-does-it-work.html for information on how attrs works. |
| 326 | |
| 327 | If this returns False, some required metadata was not ready yet, and we need another |
| 328 | pass. |
| 329 | """ |
| 330 | with state.strict_optional_set(ctx.api.options.strict_optional): |
| 331 | # This hook is called during semantic analysis, but it uses a bunch of |
| 332 | # type-checking ops, so it needs the strict optional set properly. |
| 333 | return attr_class_maker_callback_impl( |
| 334 | ctx, auto_attribs_default, frozen_default, slots_default |
| 335 | ) |
| 336 | |
| 337 | |
| 338 | def attr_class_maker_callback_impl( |
nothing calls this directly
no test coverage detected
searching dependent graphs…