-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent a recursion error to happen when inferring the declared metac…
…lass of a class Close #749
- Loading branch information
1 parent
04f5853
commit 00bcf7b
Showing
6 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
17 changes: 17 additions & 0 deletions
17
tests/testdata/python3/data/metaclass_recursion/monkeypatch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://github.com/PyCQA/astroid/issues/749 | ||
# Not an actual module but allows us to reproduce the issue | ||
from tests.testdata.python3.data.metaclass_recursion import parent | ||
|
||
class MonkeyPatchClass(parent.OriginalClass): | ||
_original_class = parent.OriginalClass | ||
|
||
@classmethod | ||
def patch(cls): | ||
if parent.OriginalClass != MonkeyPatchClass: | ||
cls._original_class = parent.OriginalClass | ||
parent.OriginalClass = MonkeyPatchClass | ||
|
||
@classmethod | ||
def unpatch(cls): | ||
if parent.OriginalClass == MonkeyPatchClass: | ||
parent.OriginalClass = cls._original_class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# https://github.com/PyCQA/astroid/issues/749 | ||
class OriginalClass: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters