-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
enable the mypy "truthy-bool" error code #9409
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,9 +56,8 @@ def roundtrip(expected: Image.Image) -> None: | |
| def test_sanity(tmp_path: Path) -> None: | ||
| # Segfault test | ||
| app: QApplication | None = QApplication([]) | ||
| ex = Example() | ||
| ex = Example() # noqa: F841 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what the idea here is, but it looked as if the assert was purely there to avoid this
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it not preferable to avoid
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I prefer being explicit about ignored errors. And |
||
| assert app # Silence warning | ||
| assert ex # Silence warning | ||
|
|
||
| for mode in ("1", "RGB", "RGBA", "L", "P"): | ||
| # to QPixmap | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -438,33 +438,28 @@ def preinit() -> None: | |
| return | ||
|
|
||
| try: | ||
| from . import BmpImagePlugin | ||
| from . import BmpImagePlugin as BmpImagePlugin | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might look a bit weird (unless you're used to writing type stubs), but it avoids a |
||
|
|
||
| assert BmpImagePlugin | ||
| except ImportError: | ||
| pass | ||
| try: | ||
| from . import GifImagePlugin | ||
| from . import GifImagePlugin as GifImagePlugin | ||
|
|
||
| assert GifImagePlugin | ||
| except ImportError: | ||
| pass | ||
| try: | ||
| from . import JpegImagePlugin | ||
| from . import JpegImagePlugin as JpegImagePlugin | ||
|
|
||
| assert JpegImagePlugin | ||
| except ImportError: | ||
| pass | ||
| try: | ||
| from . import PpmImagePlugin | ||
| from . import PpmImagePlugin as PpmImagePlugin | ||
|
|
||
| assert PpmImagePlugin | ||
| except ImportError: | ||
| pass | ||
| try: | ||
| from . import PngImagePlugin | ||
| from . import PngImagePlugin as PngImagePlugin | ||
|
|
||
| assert PngImagePlugin | ||
| except ImportError: | ||
| pass | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,7 +110,7 @@ def _load_pilfont(self, filename: str) -> None: | |
| except Exception: | ||
| pass | ||
| else: | ||
| if image and image.mode in ("1", "L"): | ||
| if image.mode in ("1", "L"): | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at this point |
||
| break | ||
| else: | ||
| if image: | ||
|
|
||
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 could also change this to an
assert isinstanceor something, but I figured that'd also be kinda obvious.