Skip to content
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

Fix some PEP-8 violations in Python code #5295

Merged
merged 8 commits into from May 23, 2021

Conversation

orsinium
Copy link
Contributor

PEP-8 is an optional (but strongly recommended) code style advised by the Python core dev team for Python code. This PR fixes some of the PEP-8 violations. It's hard to fix all of them, though. For instance, PEP-8 recommends avoiding wildcard imports but Z3 heavily relies on them.

Anyway, this is what is fixed:

  1. Bare except: block replaced by more precise exceptions handled (except Exception:)
  2. Wrap too long lines. PEP-8 advises 80 chars line length limit but I decided to be less strict and wrap everything to 120 chars.
  3. Make some isinstance check shorter: use isinstance(a, (int, str)) instead of isinstance(a, int) or isinstance(a, str)
  4. Autoformat code using autopep8 in aggressive mode: drop trailing whitespaces, separate top-level declarations by 2 blank lines, use a is None instead of a == None, wrap binary operations with single whitespaces, use 4 whitespaces for indentation, start comments from single #.
  5. Autoformat code using unify: use double quotes for all string literals for consistency.
  6. Use sys.version_info instead of sys.version.

There are still remain a few violations reported by flake8 but they are potential bugs and so require a more thoughtful approach. This PR is already huge, so I want to keep it simple and safe, with mostly stylistic changes.

@ghost
Copy link

ghost commented May 23, 2021

CLA assistant check
All CLA requirements met.

@NikolajBjorner NikolajBjorner merged commit 3d8865d into Z3Prover:master May 23, 2021
@orsinium orsinium deleted the flake8 branch May 24, 2021 07:09
@orsinium
Copy link
Contributor Author

Thank you!

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.

None yet

2 participants