Skip to content

Conversation

@cclauss
Copy link
Contributor

@cclauss cclauss commented Sep 3, 2021

Summary

Results: https://github.com/cclauss/pycord/actions
Failing tests resolved in #75 and #76

https://flake8.pycqa.org/en/latest/user/error-codes.html

On the flake8 test selection, this PR does not focus on "style violations" (the majority of flake8 error codes that psf/black can autocorrect). Instead, these tests focus on runtime safety and correctness:

  • E9 tests are about Python syntax errors usually raised because flake8 can not build an Abstract Syntax Tree (AST). Often these issues are a sign of unused code or code that has not been ported to Python 3. These would be compile-time errors in a compiled language but in a dynamic language like Python, they result in the script halting/crashing on the user.
  • F63 tests are usually about the confusion between identity and equality in Python. Use ==/!= to compare str, bytes, and int literals is the classic case. These are areas where a == b is True but a is b is False (or vice versa). Python >= 3.8 will raise SyntaxWarnings on these instances.
  • F7 tests logic errors and syntax errors in type hints
  • F82 tests are almost always undefined names which are usually a sign of a typo, missing imports, or code that has not been ported to Python 3. These also would be compile-time errors in a compiled language but in Python, a NameError is raised which will halt/crash the script on the user.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new tests).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@cclauss
Copy link
Contributor Author

cclauss commented Sep 6, 2021

@hugovk Can I please get your advise on why flake8 is raising F722 and F821 errors on examples/app_commands/slash_options.py? #76

Mypy (#81) suggests:

examples/app_commands/slash_options.py:13: error: Invalid type comment or annotation
examples/app_commands/slash_options.py:13: note: Suggestion: use Option[...] instead of Option(...)
examples/app_commands/slash_options.py:14: error: Invalid type comment or annotation
examples/app_commands/slash_options.py:14: note: Suggestion: use Option[...] instead of Option(...)
examples/app_commands/slash_options.py:15: error: Invalid type comment or annotation
examples/app_commands/slash_options.py:15: note: Suggestion: use Option[...] instead of Option(...)

@cclauss cclauss mentioned this pull request Sep 6, 2021
6 tasks
@hugovk
Copy link

hugovk commented Sep 6, 2021

Hi! I'm not so familiar with type annotations, https://stackoverflow.com/a/64917499/724176 shows some annotations which are incompatible with PEP 484, which pyflakes uses. The suggestion is to come up with PEP 484-compatible annotations, or to ignore the errors in Flake8.

@cclauss cclauss closed this Sep 24, 2021
@cclauss cclauss deleted the flake8 branch September 24, 2021 06:21
DA-344 pushed a commit to DA-344/pycord that referenced this pull request Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants