Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fake __getattribute__ to AbstractSandbox to let type-checkers know it has a bunch of dynamic methods #4708

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Oct 28, 2024

Summary of changes

Follow-up to #4504, works towards #2345

Given that AbstractSandbox isn't even public API (afaik) and that the methods are created based on os availability, I figured simply marking it as "having dynamically created methods" was cleaner than trying to duplicate all the methods in a TYPE_CHECKING block like https://github.com/python/typeshed/pull/10058/files#diff-f3cbc40d076f82bceeedca2749a2d93fbb40a03e1bb4bc837de6e990823e381fR29-R56 (typeshed doesn't have any of these methods typed anyway)

This trades false-positives if trying to call one of these methods directly, for false-negatives if you try to call an AbstractSandox method that doesn't exist.

Pull Request Checklist

  • Changes have tests (this reduces potential false-positives in type-checking tests)
  • News fragment added in newsfragments/. (this shouldn't affect runtime in any way)
    (See documentation for details)

@Avasam Avasam force-pushed the AbstractSandbox-dynamic-methods branch from a780020 to e3d3e98 Compare October 31, 2024 14:03
@abravalheri abravalheri merged commit a6e5b7e into pypa:main Oct 31, 2024
22 of 24 checks passed
@Avasam Avasam deleted the AbstractSandbox-dynamic-methods branch October 31, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants