-
-
Notifications
You must be signed in to change notification settings - Fork 954
[Analyzer Comments]: Changes for Upgrade to Python 3.13 #2392
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0237263
Changed pylint comment files to accomodate new pylint code examples. …
BethanyG 64cd525
Update analyzer-comments/python/general/general_recommendations.md
BethanyG 0f86268
Update analyzer-comments/python/pylint/convention.md
BethanyG 145feb6
Update analyzer-comments/python/pylint/refactor.md
BethanyG 33e15f1
Code review changes and re-arranging for clarity.
BethanyG 0cfa94f
Updated other PyLint error message classes for Python 3.13.
BethanyG 05bffe7
More suggestions from code review and changed inline links to reflinks.
BethanyG 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
32 changes: 32 additions & 0 deletions
32
analyzer-comments/python/general/general_recommendations.md
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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| 1. Get familiar with the conventions outlined in [PEP 8][pep-8]. | ||
| While these are not "law", they are the standard used in the Python project itself and are a great baseline in most coding situations. | ||
| 2. Read and think about the ideas outlined in [PEP 20 (aka "The Zen of Python")][pep-20]. | ||
| Like PEP 8, these are not "laws", but they are solid guiding principles for better and clearer Python code. | ||
| 3. Prefer clear and easy to follow code over comments. But DO comment where needed for clarity. | ||
| 4. Consider using type hints to clarify your code. | ||
| Explore the type hint [documentation][type-hint-docs] and [why you might not want to type hint][type-hint-nos]. | ||
| 5. Try to follow the docstring guidelines laid out in [PEP 257][pep-257]. | ||
| Good documentation matters. | ||
| 6. Avoid [magic numbers][magic-numbers]. | ||
| 7. Prefer [`enumerate()`][enumerate-docs] over [`range(len())`][range-docs] in loops that need both an index and element. | ||
| 8. Prefer [comprehensions][comprehensions] and [generator expressions][generators] over loops that append to a data structure. | ||
| But don't [overuse comprehensions][comprehension-overuse]. | ||
| 9. When joining more than few substrings or concatenating in a loop, prefer [`str.join()`][join] over other methods of string concatenation. | ||
| 10. Get familiar with Python's rich set of [built-in functions][built-in-functions] and the [Standard Library][standard-lib]. | ||
| Go [here][standard-lib-overview] for a brief tour and some interesting highlights. | ||
|
|
||
| [built-in-functions]: https://docs.python.org/3/library/functions.html | ||
| [comprehension-overuse]: https://treyhunner.com/2019/03/abusing-and-overusing-list-comprehensions-in-python/ | ||
| [comprehensions]: https://treyhunner.com/2015/12/python-list-comprehensions-now-in-color/ | ||
| [enumerate-docs]: https://docs.python.org/3/library/functions.html#enumerate | ||
| [generators]: https://www.pythonmorsels.com/how-write-generator-expression/ | ||
| [join]: https://docs.python.org/3/library/stdtypes.html#str.join | ||
| [magic-numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming) | ||
| [pep-20]: https://peps.python.org/pep-0020/ | ||
| [pep-257]: https://peps.python.org/pep-0257/ | ||
| [pep-8]: https://peps.python.org/pep-0008/ | ||
| [range-docs]: https://docs.python.org/3/library/functions.html#func-range | ||
| [standard-lib-overview]: https://docs.python.org/3/tutorial/stdlib.html | ||
| [standard-lib]: https://docs.python.org/3/library/index.html | ||
| [type-hint-docs]: https://typing.python.org/en/latest/index.html | ||
| [type-hint-nos]: https://typing.python.org/en/latest/guides/typing_anti_pitch.html |
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,9 +1,15 @@ | ||
| # pylint convention | ||
|
|
||
| **Line %{lineno}** [_%{code}_] : %{message} was reported by Pylint. | ||
| **Line %{lineno} [_%{code}_]** was reported by Pylint: | ||
|
|
||
| Which means this code doesn't follow general [code style][code style] conventions. | ||
| While this type of issue generally doesn't affect the way code _executes_, it can hurt | ||
| readability or the performance of automated tools such as documentation generators or test runners. | ||
| %{message}. | ||
|
|
||
| [code style]: https://www.python.org/dev/peps/pep-0008/ | ||
| This code doesn't follow general [Python code style][code style] conventions. | ||
| While this type of issue generally doesn't affect the way code _executes_, it can hurt readability or the performance of automated tools such as documentation generators or test runners. | ||
|
|
||
| %Q{Instead of:\n\n```python\n#{bad_code}\n```\n} | ||
| %Q{Try:\n\n```python\n#{good_code}\n```\n\n} | ||
| %Q{Additional information:\n #{related_info}\n} | ||
| %{details} | ||
|
|
||
| [code style]: https://www.python.org/dev/peps/pep-0008/ | ||
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,5 +1,13 @@ | ||
| # pylint informational | ||
|
|
||
| **Line %{lineno}** [_%{code}_] : %{message} was reported by Pylint. | ||
| **Line %{lineno} [_%{code}_]** was reported by Pylint: | ||
|
|
||
| %{message}. | ||
|
|
||
| This code has an error or problem that should be addressed. | ||
|
|
||
| %Q{Instead of:\n\n```python\n#{bad_code}\n```\n} | ||
| %Q{Try:\n\n```python\n#{good_code}\n```\n\n} | ||
| %Q{Additional information:\n #{related_info}\n} | ||
| %{details} | ||
|
|
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,5 +1,8 @@ | ||
| # pylint fatal | ||
|
|
||
| **Line %{lineno}** [_%{code}_] : %{message} was reported by Pylint. | ||
| **Line %{lineno} [_%{code}_]** was reported by Pylint: | ||
|
|
||
| %{message}. | ||
|
|
||
|
|
||
| This is a fatal error. Something went wrong, and the code cannot be processed any further. |
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,13 @@ | ||
| # pylint informational | ||
|
|
||
| **Line %{lineno} [_%{code}_]** was reported by Pylint: | ||
|
|
||
| **Line %{lineno}** [_%{code}_] : %{message} was reported by Pylint. | ||
| %{message}. | ||
|
|
||
| There is `FIXME`/`TODO`/`XXX` style comment or other "informational" pattern or note in the code. | ||
| These tags are often used to annotate places where code is stubbed out but needs work - or to highlight potential design flaws or bugs that need to be addressed in the future. | ||
|
|
||
| %Q{Instead of:\n\n```python\n#{bad_code}\n```\n} | ||
| %Q{Try:\n\n```python\n#{good_code}\n```\n\n} | ||
| %Q{Additional information:\n #{related_info}\n} | ||
| %{details} |
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,11 +1,18 @@ | ||
| # pylint refactor | ||
|
|
||
| **Line %{lineno}** [_%{code}_] : %{message} was reported by Pylint. | ||
| **Line %{lineno} [_%{code}_]** was reported by Pylint: | ||
|
|
||
| %{message}. | ||
|
|
||
| This code is emitting a [code smell][code smell], and may be in need of | ||
| a re-write or refactor. | ||
| This doesn't mean the code is incorrect or buggy in a _technical sense_ -- only that it | ||
| This doesn't mean the code is incorrect or buggy in a _technical sense_, only that it | ||
| appears to have one or more patterns that could lead to _future_ bugs or maintenance issues. | ||
| Consider taking a closer look at it. | ||
|
|
||
| %Q{Instead of:\n\n```python\n#{bad_code}\n```\n} | ||
| %Q{Try:\n\n```python\n#{good_code}\n```\n\n} | ||
| %Q{Additional information:\n #{related_info}\n} | ||
| %{details} | ||
|
|
||
| [code smell]: https://en.wikipedia.org/wiki/Code_smell |
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,8 +1,15 @@ | ||
| # pylint warning | ||
|
|
||
| **Line %{lineno}** [_%{code}_] : %{message} was reported by Pylint. | ||
| **Line %{lineno} [_%{code}_]** was reported by Pylint: | ||
|
|
||
| %{message}. | ||
|
|
||
| There is an issue in the code that could lead to a bug or error in the program. | ||
| While this error might not be _severe_, it could lead to more severe issues in the future. | ||
| It is recommend the problem be addressed before proceeding further. | ||
| It is recommended the problem be addressed before proceeding further. | ||
|
|
||
| %Q{Instead of:\n\n```python\n#{bad_code}\n```\n} | ||
| %Q{Try:\n\n```python\n#{good_code}\n```\n\n} | ||
| %Q{Additional information:\n #{related_info}\n} | ||
| %{details} | ||
|
|
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.