Fix some PEP-8 violations in Python code #5295
Merged
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.
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:
except:
block replaced by more precise exceptions handled (except Exception:
)isinstance
check shorter: useisinstance(a, (int, str))
instead ofisinstance(a, int) or isinstance(a, str)
a is None
instead ofa == None
, wrap binary operations with single whitespaces, use 4 whitespaces for indentation, start comments from single#
.sys.version_info
instead ofsys.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.