Skip to content

Complete stubtest and fix any subclassing in tqdm #9525

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

Merged
merged 11 commits into from
Feb 7, 2023

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Jan 14, 2023

Split off from #9505

Fixes the last two Any subclassing issues for #9491

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Avasam Avasam mentioned this pull request Feb 1, 2023
@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about how maintainable this is going to be :(

Stubtest will warn us if significant changes are made to _rich_shims.ProgressColumn, because it's a superclass of tqdm.rich.FractionColumn and tqdm.rich.RateColumn -- if changes to _rich_shims.ProgressColumn are made at runtime, stubtest will complain that tqdm.rich.FractionColumn and tqdm.rich.RateColumn are inconsistent.

But for the other classes in _rich_shims.pyi, I don't think we'll get any coverage from stubtest at all, and that worries me.

@Avasam
Copy link
Collaborator Author

Avasam commented Feb 3, 2023

I'm concerned about how maintainable this is going to be :(
[...]
But for the other classes in _rich_shims.pyi, I don't think we'll get any coverage from stubtest at all, and that worries me.

I don't mind simplifying and removing parts of the shim that can't be validated by stubtest (I'll try a few things so I'm confident in what is or isn't validated) as long as we have the structure of ProgressColumn (even if attributes and methods end up untyped)

@AlexWaygood
Copy link
Member

I don't mind simplifying and removing parts of the shim that can't be validated by stubtest (I'll try a few things so I'm confident in what is or isn't validated) as long as we have the structure of ProgressColumn (even if attributes and methods end up untyped)

That sounds like a great plan to me 👍

@Avasam
Copy link
Collaborator Author

Avasam commented Feb 3, 2023

stubtest doesn't seem to care what I do with ProgressColumn 😕 I added random parameters and methods. Removed exisitng ones (with ignore_missing_stub = false) and it always passes.
It only cares about the ABCMeta metaclass if I remove the ABC baseclass.

@Avasam Avasam changed the title Fix Any subclassing in tqdm/rich Complete stubtest in tqdm Feb 6, 2023
@AlexWaygood
Copy link
Member

stubtest doesn't seem to care what I do with ProgressColumn 😕 I added random parameters and methods. Removed exisitng ones (with ignore_missing_stub = false) and it always passes. It only cares about the ABCMeta metaclass if I remove the ABC baseclass.

That's a bummer :/ I guess something like the patch described in #3968 (comment) would help with that somewhat.

I still feel like I'm okay with ProgressColumn being typed in detail, but a bit wary of some of the others being typed in so much detail. Even if it's not something that stubtest tests now, it feels like the kind of thing that should be stubtestable. With the other classes, it feels more dangerous

@Avasam Avasam changed the title Complete stubtest in tqdm Complete stubtest and fix any subclassing in tqdm Feb 6, 2023
@Avasam
Copy link
Collaborator Author

Avasam commented Feb 6, 2023

Yeah I decided to only keep rich.progress.ProgressColumn as well. Changed the focus to "completing stubtest" since fixing the metaclass issue incidentaly fixes the Any subclassing. And even if stubtest "should" catch missing methods, ignore_missing_stub = false would need to be set for that.

@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for your patience and for being willing to revise this :)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit 29d9aa9 into python:main Feb 7, 2023
@Avasam Avasam deleted the tqdm-any-subclassing-rich branch February 7, 2023 00:19
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