-
Notifications
You must be signed in to change notification settings - Fork 258
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
fix: warn on deprecated images being set #2312
Conversation
Signed-off-by: Henry Schreiner <[email protected]>
a4ed9aa
to
9fa0075
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd want to check that the warning doesn't fire loads of times? I think that build_options()
is called rather a lot... at least, once per identifier. Perhaps we'd need an instance variable tracking which deprecated images have already been seen.
Signed-off-by: Henry Schreiner <[email protected]>
cibuildwheel/logger.py
Outdated
@@ -164,7 +165,11 @@ def notice(self, message: str) -> None: | |||
c = self.colors | |||
print(f"cibuildwheel: {c.bold}note{c.end}: {message}\n", file=sys.stderr) | |||
|
|||
def warning(self, message: str) -> None: | |||
def warning(self, message: str, *, deduplicate: bool = False) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could just always do this for warnings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think I'd prefer to keep it explicit, it's a bit surprising at the call site otherwise. Might also make some unit tests buggy as this is shared global state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ actually the global state thing might be a reason to do it on Options rather than here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was originally going to make it global as a ClassVar
in options. I guess if it was an instance variable it still wouldn't over trigger? It's pretty common for warning to be only shown once globally (the "default" setting for warnings in Python, for example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if it was an instance variable it still wouldn't over trigger?
I don't think so. There's only one instance of Options
in a normal running process. The only reason I hesitate to do it globally is that I can imagine a unit test expecting to see a warning but depending on test execution order, it sometimes gets triggered somewhere else and the test becomes flaky/hard to debug.
That said it's a hypothetical issue at this point, we can leave it here if you wish.
cibuildwheel/logger.py
Outdated
@@ -164,7 +165,11 @@ def notice(self, message: str) -> None: | |||
c = self.colors | |||
print(f"cibuildwheel: {c.bold}note{c.end}: {message}\n", file=sys.stderr) | |||
|
|||
def warning(self, message: str) -> None: | |||
def warning(self, message: str, *, deduplicate: bool = False) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think I'd prefer to keep it explicit, it's a bit surprising at the call site otherwise. Might also make some unit tests buggy as this is shared global state.
Co-authored-by: Joe Rickerby <[email protected]>
Signed-off-by: Henry Schreiner <[email protected]>
1c3d5c4
to
8a190f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for putting it together. I'll roll this into a 2.x patch release.
* fix: warn on deprecated images being set Signed-off-by: Henry Schreiner <[email protected]> * fix: handle repeated warning messages Signed-off-by: Henry Schreiner <[email protected]> * Apply suggestions from code review Co-authored-by: Joe Rickerby <[email protected]> * fix: try making the warnings once per Options Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: Joe Rickerby <[email protected]>
See #2047.