Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rework axes/__init__.pyi to not use __all__
  • Loading branch information
ksunden committed Sep 25, 2023
commit 0c6a3b0d2cb5de809a928dc6e3b0fb4f713e8fb0
13 changes: 5 additions & 8 deletions lib/matplotlib/axes/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
__all__ = [
'Axes',
'Subplot',
'SubplotBase',
]

from typing import TypeVar

from ._axes import *
from ._axes import Axes as Subplot
from ._axes import Axes as Axes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since that's the only thing in there, should we change the import in the .py file, too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I mean, logically yes, but technically at runtime more gets imported there, just not things we intend to re-export.

I was being a bit conservative here and only changing stub behavior (especially since the stubs didn't pick up Subplot as being exported, when it should be)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I actually think __init__.py files (broadly) are good candidates for inlining type hints and just not having separate files: they are short, contain little to no actual function definitions, it's mostly imports and __all__ (which I'm also in favor of adding in more places)



_T = TypeVar("_T")

# Backcompat.
Subplot = Axes
Comment thread
QuLogic marked this conversation as resolved.

class _SubplotBaseMeta(type):
def __instancecheck__(self, obj) -> bool: ...

Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/axes/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ class _AxesBase(martist.Artist):
def clear(self) -> None: ...
def cla(self) -> None: ...

# Could be made generic, but comments indicate it may be temporary anyway
class ArtistList(Sequence[_T]):
def __init__(
self,
Expand Down