-
Notifications
You must be signed in to change notification settings - Fork 726
Implement Ruff rules and perform comprehensive code cleanup. #408
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
94fd322
Implement Ruff rules and perform comprehensive code cleanup.
bartTC 82729c2
Reformat Imports
bartTC b132ef9
Removed backwards-compatible imports for PIL drawers in qrcode.image.…
bartTC 7528208
Revert "Removed backwards-compatible imports for PIL drawers in qrcod…
bartTC eb73ec6
Make an import from 'moduledrawers' directly raise a deprecation warning
bartTC c38fb6f
Add a global constant whether PIL is available or not.
bartTC c473ebb
Test and document deprecations.
bartTC fa212b7
Simplify Import handling within tests for Ruff
bartTC b2a1f3f
Revert contextlib change to improve performance.
bartTC f6e1715
Fix tuple annotation
bartTC 2096319
Revert EM101 102
bartTC 84b31ec
Refactor temporary file handling in tests and simplify deprecation te…
bartTC d453a5e
File is automatically deleted
bartTC 60fdcc2
Revert supress change
bartTC 8d1ae53
Merge branch 'main' into ruff-fixes
bartTC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,31 +7,31 @@ name = "qrcode" | |
| version = "8.2" | ||
| description = "QR Code image generator" | ||
| authors = [ | ||
| { name = "Lincoln Loop", email = "[email protected]" }, | ||
| { name = "Lincoln Loop", email = "[email protected]" }, | ||
| ] | ||
| license = { text = "BSD-3-Clause" } | ||
| dynamic = [ "readme" ] | ||
| dynamic = ["readme"] | ||
| keywords = ["qr", "denso-wave", "IEC18004"] | ||
| classifiers = [ | ||
| "Development Status :: 5 - Production/Stable", | ||
| "License :: OSI Approved :: BSD License", | ||
| "Operating System :: OS Independent", | ||
| "Intended Audience :: Developers", | ||
| "Programming Language :: Python", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Programming Language :: Python :: 3 :: Only", | ||
| "Topic :: Multimedia :: Graphics", | ||
| "Topic :: Software Development :: Libraries :: Python Modules", | ||
| "Development Status :: 5 - Production/Stable", | ||
| "License :: OSI Approved :: BSD License", | ||
| "Operating System :: OS Independent", | ||
| "Intended Audience :: Developers", | ||
| "Programming Language :: Python", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Programming Language :: Python :: 3 :: Only", | ||
| "Topic :: Multimedia :: Graphics", | ||
| "Topic :: Software Development :: Libraries :: Python Modules", | ||
| ] | ||
| requires-python = "~=3.9" | ||
| dependencies = [ | ||
| "colorama; sys_platform == 'win32'", | ||
| "deprecation", | ||
| "colorama; sys_platform == 'win32'", | ||
| "deprecation", | ||
| ] | ||
|
|
||
|
|
||
|
|
@@ -51,7 +51,7 @@ changelog = "https://github.com/lincolnloop/python-qrcode/blob/main/CHANGES.rst" | |
| qr = "qrcode.console_scripts:main" | ||
|
|
||
| [tool.poetry] | ||
| packages = [{include = "qrcode"}] | ||
| packages = [{ include = "qrcode" }] | ||
| readme = ["README.rst", "CHANGES.rst"] | ||
|
|
||
| # There is no support for data files yet. | ||
|
|
@@ -62,24 +62,24 @@ readme = ["README.rst", "CHANGES.rst"] | |
| # ] | ||
|
|
||
| [tool.poetry.group.dev.dependencies] | ||
| pytest = {version = "*"} | ||
| pytest-cov = {version = "*"} | ||
| tox = {version = "*"} | ||
| ruff = {version = "*"} | ||
| pypng = {version = "*"} | ||
| pillow = {version = ">=9.1.0"} | ||
| pytest = { version = "*" } | ||
| pytest-cov = { version = "*" } | ||
| tox = { version = "*" } | ||
| ruff = { version = "*" } | ||
| pypng = { version = "*" } | ||
| pillow = { version = ">=9.1.0" } | ||
| docutils = "^0.21.2" | ||
| zest-releaser = {extras = ["recommended"], version = "^9.2.0"} | ||
| zest-releaser = { extras = ["recommended"], version = "^9.2.0" } | ||
|
|
||
| [tool.zest-releaser] | ||
| less-zeros = "yes" | ||
| version-levels = 2 | ||
| tag-format = "v{version}" | ||
| tag-message = "Version {version}" | ||
| tag-signing = "yes" | ||
| date-format =" %%-d %%B %%Y" | ||
| date-format = " %%-d %%B %%Y" | ||
| prereleaser.middle = [ | ||
| "qrcode.release.update_manpage" | ||
| "qrcode.release.update_manpage" | ||
| ] | ||
|
|
||
| [tool.coverage.run] | ||
|
|
@@ -88,10 +88,53 @@ parallel = true | |
|
|
||
| [tool.coverage.report] | ||
| exclude_lines = [ | ||
| "@abc.abstractmethod", | ||
| "@overload", | ||
| "if (typing\\.)?TYPE_CHECKING:", | ||
| "pragma: no cover", | ||
| "raise NotImplementedError" | ||
| "@abc.abstractmethod", | ||
| "@overload", | ||
| "if (typing\\.)?TYPE_CHECKING:", | ||
| "pragma: no cover", | ||
| "raise NotImplementedError" | ||
| ] | ||
| skip_covered = true | ||
|
|
||
| [tool.ruff] | ||
| target-version = "py39" | ||
| exclude = ["migrations"] | ||
| lint.select = ["ALL"] | ||
| lint.ignore = [ | ||
| # Safe to ignore | ||
| "A001", # Variable is shadowing a Python builtin | ||
| "A002", # Function argument is shadowing a Python builtin | ||
| "ANN", # Missing Type Annotation | ||
| "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`" | ||
| "ARG001", # Unused function argument (request, ...) | ||
| "ARG002", # Unused method argument (*args, **kwargs) | ||
| "ARG005", # Unused lambda argument | ||
| "D", # Missing or badly formatted docstrings | ||
| "E501", # Line too long (>88) | ||
| "ERA001", # Found commented-out code | ||
| "FBT", # Flake Boolean Trap (don't use arg=True in functions) | ||
| "N999", # Invalid module name | ||
| "PLR091", # Too many statements/branches/arguments | ||
| "PLR2004", # Magic value used in comparison, consider replacing <int> with a constant variable | ||
| "RUF012", # Mutable class attributes https://github.com/astral-sh/ruff/issues/5243 | ||
| "SLF001", # private-member-access | ||
|
|
||
| # Should be fixed later | ||
| "C901", # Too complex | ||
| "N802", # Function name should be lowercase | ||
| "N803", # Argument name should be lowercase | ||
| "N806", # Variable should be lowercase | ||
| "PERF401", # Use `list.extend` to create a transformed list | ||
| "S101", # Use of 'assert' detected | ||
|
|
||
| # Required for `ruff format` to work correctly | ||
| "COM812", # Checks for the absence of trailing commas | ||
| "ISC001", # Checks for implicitly concatenated strings on a single line | ||
| ] | ||
|
|
||
| [tool.ruff.lint.extend-per-file-ignores] | ||
| "qrcode/tests/*.py" = [ | ||
| "S101", # Use of 'assert' detected | ||
| "S603", # `subprocess` call: check for execution of untrusted input | ||
| "PT011", # pytest.raises is too broad | ||
| ] | ||
This file contains hidden or 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 file contains hidden or 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 file contains hidden or 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 file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| try: | ||
| import lxml.etree as ET # type: ignore # noqa: F401 | ||
| import lxml.etree as ET # noqa: N812 | ||
| except ImportError: | ||
| import xml.etree.ElementTree as ET # type: ignore # noqa: F401 | ||
| import xml.etree.ElementTree as ET # noqa: F401 |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import contextlib | ||
|
|
||
| # Try to import png library. | ||
| PngWriter = None | ||
|
|
||
| try: | ||
| from png import Writer as PngWriter # type: ignore # noqa: F401 | ||
| except ImportError: # pragma: no cover | ||
| pass | ||
| with contextlib.suppress(ImportError): | ||
|
bartTC marked this conversation as resolved.
Outdated
|
||
| from png import Writer as PngWriter # noqa: F401 | ||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.