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

BUG: hotfix for a functional breakage introduced in #3546 #3692

Merged
merged 1 commit into from
Nov 22, 2021

Conversation

neutrinoceros
Copy link
Member

@neutrinoceros neutrinoceros commented Nov 22, 2021

PR Summary

This should resolve the docs part of #3690

For reproduction:

import yt

ds = yt.load_sample("IsolatedGalaxy")
p = yt.SlicePlot(ds, "z", "density")
p.annotate_title("test")
p.save("/tmp/")

@matthewturk
Copy link
Member

OK, so why is this now a bug, when it wasn't before, and when we explicitly said all the typing stuff would be optional? I'm confused, and this needs to be figured out before we do anything else.

@neutrinoceros
Copy link
Member Author

This is because #3546 never triggered the docs build, and apparently the only tests we have that exercise what's broken here are in there

@matthewturk
Copy link
Member

@neutrinoceros Why is this an error if it's just typing? Because of mypy?

@@ -55,7 +55,7 @@ class PlotCallback:
# "figure" this is disregarded. If "force" is included in the tuple, it
# will *not* check whether or not the coord_system is in axis or figure,
# and will only look at the geometries.
_supported_geometries: Tuple[str, ...]
_supported_geometries: Optional[Tuple[str, ...]] = None
Copy link
Member

Choose a reason for hiding this comment

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

So the Optional is so that it's not required to be defined in subclasses, right? Not that it isn't required to be defined as an attribute? This is rather frustrating if this is the case, because if that is correct, it seems like it may be pointless to have anything in a base class that is typed as anything other than Optional. Is that the case?

Copy link
Member Author

@neutrinoceros neutrinoceros Nov 22, 2021

Choose a reason for hiding this comment

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

It's not. Optional[Tuple] is short for Union[None, Tuple], but the name is indeed confusing. It's going away in Python 3.10 where we can replace it with None | Tuple, so we don't have to live with it for ever.

@neutrinoceros
Copy link
Member Author

It's not just typing, apparently I removed the default value for PlotCallback._supported_geometries in my typing PR. I was expecting CI to call me out when I broke things (and indeed, it happened a couple times), but it seems like this slipped in still

@matthewturk
Copy link
Member

I see, ok.

@matthewturk matthewturk merged commit d4d833b into yt-project:main Nov 22, 2021
@neutrinoceros neutrinoceros deleted the hotfix_callback_breakage branch November 22, 2021 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants