-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Better message for truthy functions #15193
Merged
hauntsaninja
merged 9 commits into
python:master
from
madt2709:better-message-for-truthy-functions
May 13, 2023
Merged
Better message for truthy functions #15193
hauntsaninja
merged 9 commits into
python:master
from
madt2709:better-message-for-truthy-functions
May 13, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hauntsaninja
approved these changes
May 13, 2023
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.
Overall looks great! Just had a minor comment
This comment has been minimized.
This comment has been minimized.
Thanks for the review @hauntsaninja! |
Diff from mypy_primer, showing the effect of this PR on open source code: arviz (https://github.com/arviz-devs/arviz)
- arviz/tests/base_tests/test_utils.py:250: error: Function "Callable[[Any, Any], Any]" could always be true in boolean context [truthy-function]
+ arviz/tests/base_tests/test_utils.py:250: error: Function "_stack" could always be true in boolean context [truthy-function]
spark (https://github.com/apache/spark)
- python/pyspark/ml/torch/distributor.py:658: error: Function "Callable[..., Any]" could always be true in boolean context [truthy-function]
+ python/pyspark/ml/torch/distributor.py:658: error: Function "framework_wrapper_fn" could always be true in boolean context [truthy-function]
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/settings.py:1708: error: Function "Callable[[Settings, T], T]" could always be true in boolean context [truthy-function]
+ src/prefect/settings.py:1708: error: Function "value_callback" could always be true in boolean context [truthy-function]
- src/prefect/results.py:101: error: Function "Callable[[TaskRunContext, dict[str, Any]], str | None]" could always be true in boolean context [truthy-function]
+ src/prefect/results.py:101: error: Function "cache_key_fn" could always be true in boolean context [truthy-function]
- src/prefect/engine.py:1521: error: Function "Callable[[TaskRunContext, dict[str, Any]], str | None]" could always be true in boolean context [truthy-function]
+ src/prefect/engine.py:1521: error: Function "cache_key_fn" could always be true in boolean context [truthy-function]
ibis (https://github.com/ibis-project/ibis)
- ibis/common/caching.py:100: error: Function "Callable[[Any], Any]" could always be true in boolean context [truthy-function]
+ ibis/common/caching.py:100: error: Function "key" could always be true in boolean context [truthy-function]
pyppeteer (https://github.com/pyppeteer/pyppeteer)
- pyppeteer/browser.py:54: error: Function "Callable[[], Awaitable[None]]" could always be true in boolean context [truthy-function]
+ pyppeteer/browser.py:54: error: Function "closeCallback" could always be true in boolean context [truthy-function]
|
hauntsaninja
approved these changes
May 13, 2023
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 great, thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes case 1 in #14529.
If this approach is correct, I will add the rest of the cases.
Updated message + tests.
Recommend we squash the commits when we merge since they are not clean but change is small enough to be one commit.
EDIT: This PR doesn't work quite as intended with walrus operator. It outputs two error msgs for both the function value and target. This seemed the least bad solution as: