Get subject name from class.
(
first,
second,
*,
raise_error=True,
first_kind="class subject attribute",
second_kind="input subject",
)
| 305 | |
| 306 | |
| 307 | def _check_subject( |
| 308 | first, |
| 309 | second, |
| 310 | *, |
| 311 | raise_error=True, |
| 312 | first_kind="class subject attribute", |
| 313 | second_kind="input subject", |
| 314 | ): |
| 315 | """Get subject name from class.""" |
| 316 | if second is not None: |
| 317 | _validate_type(second, "str", "subject input") |
| 318 | if first is not None and first != second: |
| 319 | raise ValueError( |
| 320 | f"{first_kind} ({repr(first)}) did not match {second_kind} ({second})" |
| 321 | ) |
| 322 | return second |
| 323 | elif first is not None: |
| 324 | _validate_type(first, "str", f"Either {second_kind} subject or {first_kind}") |
| 325 | return first |
| 326 | elif raise_error is True: |
| 327 | raise ValueError(f"Neither {second_kind} subject nor {first_kind} was a string") |
| 328 | return None |
| 329 | |
| 330 | |
| 331 | def _check_preload(inst, msg): |
no test coverage detected