Repository navigation
Preserve builtin subclass types during call inference - #961
Open
2836048681 wants to merge 1 commit into
Open
2836048681 wants to merge 1 commit into
2836048681 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instances of source-defined classes inheriting a builtin
__new__were inferredas the builtin base type. For example,
WordList()was inferred as a plainlist. InliningWordList.extendcould then delete its definition withoutreplacing
words.extend(...), silently changing which implementation ran.Use the source-defined class as the instance type when its
__new__is a builtinfunction. Keep direct builtin construction and the inferred returns of
source-defined custom
__new__methods unchanged.Add regressions for six builtin bases, indirect inheritance, custom constructors,
and inlining from either the method definition or its call. The inline regression
executes the result and checks that both elements are still
Wordinstances.Update the changelog.
Fixes #828.
Validation
Python 3.12.3, Linux:
python -m pytest -q: 2176 passed, 11 skipped, 5 xfailed, 2001 warnings in 56.75s.controls passing. Failures cover four builtin bases, indirect inheritance, and
both inline selection locations. See
screening/regressions-before.log.python -m pytest ropetest/builtinstest.py ropetest/refactor/inlinetest.py -q: 171 passed, 171 warnings, 8 subtests passed in 3.18s.python -m pytest -q --cov: 2181 passed, 11 skipped, 5 xfailed, 2004 warnings, 8 subtests passed in 224.07s (0:03:44).TOTAL 26940 1271 95%.and after inlining, from both the definition and call site. Run
../.venv/bin/python ../screening/reproduce-828.pyfrom the checkout.whitespace, final newline, large-file check, Black, and isort.
python -m pip checkandgit diff --cached --checkpass.The coverage run emits a warning about a temporary fixture source deleted during
teardown. Deprecation warnings remain; there are no test failures. Other Python
versions and operating systems were not run.
Checklist