|
10 | 10 | import collections
|
11 | 11 | import collections.abc
|
12 | 12 | from collections.abc import Sequence
|
13 |
| -from typing import TYPE_CHECKING, Any |
| 13 | +from typing import Any |
14 | 14 |
|
15 |
| -from astroid import decorators |
| 15 | +from astroid import decorators, nodes |
16 | 16 | from astroid.const import PY310_PLUS
|
17 | 17 | from astroid.context import (
|
18 | 18 | CallContext,
|
|
33 | 33 | helpers = lazy_import("helpers")
|
34 | 34 | manager = lazy_import("manager")
|
35 | 35 |
|
36 |
| -if TYPE_CHECKING: |
37 |
| - from astroid import nodes |
38 |
| - |
39 | 36 |
|
40 | 37 | # TODO: check if needs special treatment
|
41 | 38 | BOOL_SPECIAL_METHOD = "__bool__"
|
@@ -293,6 +290,11 @@ class Instance(BaseInstance):
|
293 | 290 | # pylint: disable=unnecessary-lambda
|
294 | 291 | special_attributes = lazy_descriptor(lambda: objectmodel.InstanceModel())
|
295 | 292 |
|
| 293 | + def __init__(self, proxied: nodes.ClassDef) -> None: |
| 294 | + if not isinstance(proxied, nodes.ClassDef): |
| 295 | + raise TypeError |
| 296 | + super().__init__(proxied) |
| 297 | + |
296 | 298 | def __repr__(self):
|
297 | 299 | return "<Instance of {}.{} at 0x{}>".format(
|
298 | 300 | self._proxied.root().name, self._proxied.name, id(self)
|
@@ -415,9 +417,6 @@ def _infer_builtin_new(
|
415 | 417 | ) -> collections.abc.Generator[
|
416 | 418 | nodes.Const | Instance | type[Uninferable], None, None
|
417 | 419 | ]:
|
418 |
| - # pylint: disable-next=import-outside-toplevel; circular import |
419 |
| - from astroid import nodes |
420 |
| - |
421 | 420 | if not caller.args:
|
422 | 421 | return
|
423 | 422 | # Attempt to create a constant
|
|
0 commit comments