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

Update Formatting Tools #182

Merged
merged 10 commits into from
Jun 29, 2022
2 changes: 1 addition & 1 deletion .ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ stages:
inputs:
versionSpec: '3.7'
- script: |
pip install codespell pydocstyle
pip install codespell pydocstyle[toml]
make doctest
displayName: 'Run doctest'

Expand Down
4 changes: 4 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[codespell]
skip = ./.ci/*,./.git/*,./.hypothesis/*,./dist/*,./doc/examples/*,./doc/images/*,./docs/_build/*,./docs/images/*,./tests/tinypages/_build/*,.hypothesis*,*.doctree,*.eot,*.gif,*.html,*.inv,*.ipynb,*.jpg,*.js,*.json,*.mp4,*.mypy_cache/*,*.pickle,*.ply,*.png,*.pyc,*.ttf,*.txt,*.vti,*.vtk,*.vtu,*.woff,*.woff2,*.yml,*/_autosummary/*,*~,*cover,doc/_build/*,flycheck*
ignore-words-list = lod,byteorder,flem,parm,doubleclick,revered,PullRequest
quiet-level = 3
42 changes: 42 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[flake8]
max-line-length = 88
exclude =
__pycache__,
.venv,
.cache,
.eggs
.git,
.tox,
*.egg-info,
*.pyc,
*.pyi,
build,
dist,
# This is adopted from VTK
pyvistaqt/rwi.py,
# Only lint source files
tests/*.py,
docs/*.py,
# Ignore errors here in this commit (fix in future PR)
pyvistaqt/*.py,
setup.py
max-complexity = 10
doctests = true
extend-ignore =
# whitespace before ':'
E203,
# line break before binary operator
W503,
# line length too long
E501,
# do not assign a lambda expression, use a def
E731,
# missing class docstring; use ``__init__`` docstring instead
D101,
# missing docstring in magic method
D105,
# Qt uses camelCase
N802
per-file-ignores =
# Allow re-export of modules at package level
__init__.py:F401
10 changes: 10 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
[settings]
profile=black
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
ensure_newline_before_comments=True
extend_skip_glob=tests/*.py,docs/conf.py,setup.py,pyvistaqt/rwi.py
# `pre-comment` doesn't see skips; `filter_files=True` forces it
# to see these files
#
# See:
# - https://jugmac00.github.io/blog/isort-and-pre-commit-a-friendship-with-obstacles/
# - https://github.com/PyCQA/isort/issues/885
filter_files=True
108 changes: 108 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [
"--config=pyproject.toml"
]

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: [
"--check",
"--settings=.isort.cfg"
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.961
hooks:
- id: mypy
# `pass_filenames` is used to overcome the "duplicate module"
# error from occuring. We are explicitly passing a 'txt'
# file to search. This setting tells `pre-commit` to not do a
# search and pass files to check to mypy, like it normally does.
#
# See:
# - https://github.com/python/mypy/issues/4008#issuecomment-708060733
# - https://pre-commit.com/#hooks-pass_filenames
language: system
pass_filenames: false
args: [
"--config-file",
"mypy.ini",
"@mypy_checklist.txt"
]

- repo: https://gitlab.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [
"flake8-black==0.3.2",
"flake8-isort==4.1.1",
"flake8-quotes==3.3.1",
]
args: [
"--config=.flake8"
]

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
args: [
"docs examples examples_flask pyvista tests",
"*.py *.rst *.md",
]

- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
additional_dependencies: [toml==0.10.2]
# We use the 'match' and do not want pre-commit to pass
# globbed files
pass_filenames: false
args: [
"--config=pyproject.toml",
]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: no-commit-to-branch
args: [--branch, main]

# this validates our github workflow files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.16.1
hooks:
- id: check-github-workflows

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"-rn", # Only display messages
"-sn", # Don't display the score
"--rcfile=.pylintrc", # Specify rc file
]
- id: pycodestyle
name: pycodestyle
entry: pycodestyle
language: system
types: [python]
args:
[
"--config=./\\.pycodestyle",
]
8 changes: 8 additions & 0 deletions .pycodestyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[pycodestyle]
ignore = E501,
E203,
W503
exclude = tests/*.py,
docs/*.py,
rwi.py
filename = pyvistaqt/*.py
93 changes: 16 additions & 77 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=vtk
extension-pkg-whitelist=vtk,
PyQt5,
PySide2,
PyQt6,
PySide6

# Specify a score threshold to be exceeded before program exits with error.
fail-under=10

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
ignore=rwi.py,
conf.py,
conftest.py,
setup.py # ignore and fix in future PR

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
ignore-patterns=(?=(coverage|test_|rwi)).*[.]py

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
Expand Down Expand Up @@ -60,89 +67,21 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape,
bad-continuation,
arguments-differ,
no-name-in-module,
no-member
no-member,
# Redundant alias imports required for type hinting by PEP 484
useless-import-alias,
# Qt uses PascalCase
invalid-name,

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
Loading