Repository navigation
Move __getattribute__ to FakeFileWrapper - #1379
mrbean-bremen merged 4 commits into
Conversation
FakeTextFileWrapper and FakeBinaryFileWrapper had identical __getattribute__ overrides; define it once in their base class.
Defining __getattribute__ in FakeFileWrapper made pytype treat all of its attributes as dynamic, which caused a bad-return-type error in fileno(). Define it under "if not TYPE_CHECKING" so runtime behavior is unchanged while type checkers keep the real attribute types.
|
@mrbean-bremen - The previous Could you please re-run the failed job when you have a chance? Thank you! |
|
@mrbean-bremen - After merged main branch into this PR, the CI jobs were triggered again. This time, the failure occurred in Testsuite / tests (macOS-latest, 3.15), while the macOS 3.12 test suite completed successfully. |
Replace the explanatory comment with a short docstring and a brief note on the TYPE_CHECKING guard, as suggested in review.
|
The cancelled tests are a GitHub problem - they don't have enough macOS runners given the increased demand due to all the AI-generated PRs. |
This PR removes the duplicated getattribute implementation from FakeTextFileWrapper and FakeBinaryFileWrapper by moving it into their common base class, FakeFileWrapper.
Both subclasses now inherit the implementation from FakeFileWrapper.
Changed the call to object.getattribute(self, name) to avoid recursive calls after moving the method.
Added a comment explaining why the override is needed.
Since FakeFileWrapper is only used through its subclasses, this change does not affect existing behaviour. The existing tests pass locally on Windows without any modifications, and pre-commit checks also pass.
This is a small, independent refactoring PR related to my university assignment and is part of the same assignment as #1378.