diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 2d659db5..732782f0 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -11,18 +11,32 @@ on: jobs: build: runs-on: ubuntu-20.04 + env: + PYTHON_VERSION: '3.9' steps: - uses: actions/checkout@v2 - - name: Python Code Quality and Lint - uses: ricardochaves/python-lint@v1.3.0 + - uses: actions/setup-python@v2 with: - python-root-list: pyvistaqt - use-pylint: true - extra-pylint-options: --disable=F0401 - use-pycodestyle: true - use-flake8: true - use-black: true - use-mypy: true - use-isort: true - extra-pycodestyle-options: --ignore=E501,E203,W503 - extra-flake8-options: --ignore=E501,E203,W503 + python-version: ${{ env.PYTHON_VERSION }} + name: 'Setup python' + - run: | + python -m pip install --upgrade pip wheel + pip install -r requirements_test.txt + pip install --upgrade black isort pylint pycodestyle mypy flake8 codespell pydocstyle + name: 'Install dependencies with pip' + - run: make black + name: 'Run black' + - run: make isort + name: 'Run isort' + - run: make pylint + name: 'Run pylint' + - run: make pycodestyle + name: 'Run pycodestyle' + - run: make mypy + name: 'Run mypy' + - run: make flake8 + name: 'Run flake8' + - run: make codespell + name: 'Run codespell' + - run: make pydocstyle + name: 'Run pydocstyle' diff --git a/.pylintrc b/.pylintrc index 91166a43..a0629152 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,7 +3,7 @@ # 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=PyQt5, vtk +extension-pkg-whitelist=vtk # Specify a score threshold to be exceeded before program exits with error. fail-under=10 @@ -139,7 +139,10 @@ disable=print-statement, deprecated-sys-function, exception-escape, comprehension-escape, - bad-continuation + bad-continuation, + arguments-differ, + no-name-in-module, + no-member # 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 diff --git a/Makefile b/Makefile index 18609a6e..502f0885 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ PYLINT_DIRS ?= ./pyvistaqt/ MYPY_DIRS ?= ./pyvistaqt/ FLAKE8_DIRS ?= ./pyvistaqt/ CODESPELL_DIRS ?= ./ -CODESPELL_SKIP ?= "*.pyc,*.txt,*.gif,*.png,*.jpg,*.ply,*.vtk,*.vti,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./docs/_build/*,./docs/images/*,./dist/*,./.ci/*" +CODESPELL_SKIP ?= "*.json,*.pyc,*.txt,*.gif,*.png,*.jpg,*.ply,*.vtk,*.vti,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./docs/_build/*,./docs/images/*,./dist/*,./.ci/*" CODESPELL_IGNORE ?= "ignore_words.txt" EXTRA_PYCODESTYLE_OPTIONS ?= --ignore="E501,E203,W503" EXTRA_FLAKE8_OPTIONS ?= --ignore="E501,E203,W503" @@ -20,15 +20,15 @@ doctest: codespell pydocstyle black: @echo "Running black" - @black $(BLACK_DIRS) + @black --check $(BLACK_DIRS) isort: @echo "Running isort" - @isort $(ISORT_DIRS) + @isort --check $(ISORT_DIRS) pylint: @echo "Running pylint" - @pylint $(PYLINT_DIRS) + @pylint $(PYLINT_DIRS) --rcfile=.pylintrc pycodestyle: @echo "Running pycodestyle" diff --git a/pyvistaqt/counter.py b/pyvistaqt/counter.py index 3a696174..e31a7a64 100644 --- a/pyvistaqt/counter.py +++ b/pyvistaqt/counter.py @@ -17,7 +17,7 @@ def __init__(self, count: int) -> None: self.count = count elif count > 0: raise TypeError( - "Expected type of `count` to be `int` but got: {}".format(type(count)) + f"Expected type of `count` to be `int` but got: {type(count)}" ) else: raise ValueError("count is not strictly positive.") diff --git a/pyvistaqt/dialog.py b/pyvistaqt/dialog.py index a8e9cea7..c531da14 100644 --- a/pyvistaqt/dialog.py +++ b/pyvistaqt/dialog.py @@ -86,7 +86,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: """Initialize the double slider.""" super().__init__(*args, **kwargs) self.decimals = 5 - self._max_int = 10 ** self.decimals + self._max_int = 10**self.decimals super().setMinimum(0) super().setMaximum(self._max_int) diff --git a/pyvistaqt/editor.py b/pyvistaqt/editor.py index f8f7e876..3c7fb13e 100644 --- a/pyvistaqt/editor.py +++ b/pyvistaqt/editor.py @@ -59,7 +59,7 @@ def update(self) -> None: for idx, renderer in enumerate(self.renderers): actors = renderer._actors # pylint: disable=protected-access widget_idx = self.stacked_widget.addWidget(_get_renderer_widget(renderer)) - top_item = QTreeWidgetItem(self.tree_widget, ["Renderer {}".format(idx)]) + top_item = QTreeWidgetItem(self.tree_widget, [f"Renderer {idx}"]) top_item.setData(0, Qt.ItemDataRole.UserRole, widget_idx) self.tree_widget.addTopLevelItem(top_item) for name, actor in actors.items(): diff --git a/pyvistaqt/plotting.py b/pyvistaqt/plotting.py index ba5385b1..ca673929 100644 --- a/pyvistaqt/plotting.py +++ b/pyvistaqt/plotting.py @@ -102,8 +102,8 @@ class _GlobalTheme: """Wrap global_theme too rcParams.""" - def __setattr__(self, k: str, v: Any) -> None: # noqa: D105 - rcParams[k] = v + def __setattr__(self, k: str, val: Any) -> None: # noqa: D105 + rcParams[k] = val def __getattr__(self, k: str) -> None: # noqa: D105 return rcParams[k] if k != "__wrapped__" else None @@ -285,7 +285,7 @@ def __init__( # Modified() and upstream objects won't be updated. This # ensures the render window stays updated without consuming too # many resources. - twait = int((auto_update ** -1) * 1000.0) + twait = int((auto_update**-1) * 1000.0) self.render_timer.timeout.connect(self.render) self.render_timer.start(twait) @@ -419,7 +419,7 @@ def dragEnterEvent(self, event: QtGui.QDragEnterEvent) -> None: # only call accept on files event.accept() except IOError as exception: # pragma: no cover - warnings.warn("Exception when dropping files: %s" % str(exception)) + warnings.warn(f"Exception when dropping files: {str(exception)}") # pylint: disable=invalid-name,useless-return def dropEvent(self, event: QtCore.QEvent) -> None: @@ -816,9 +816,7 @@ def load_camera_position() -> None: # pylint: disable=attribute-defined-outside-init self.camera_position = camera_position - self.saved_cameras_tool_bar.addAction( - "Cam %2d" % ncam, load_camera_position - ) + self.saved_cameras_tool_bar.addAction(f"Cam {ncam}", load_camera_position) if ncam < 10: self.add_key_event(str(ncam), load_camera_position) diff --git a/pyvistaqt/utils.py b/pyvistaqt/utils.py index 7a8db98e..497b3227 100644 --- a/pyvistaqt/utils.py +++ b/pyvistaqt/utils.py @@ -10,8 +10,8 @@ def _check_type(var: Any, var_name: str, var_types: List[Type[Any]]) -> None: types = tuple(var_types) if not isinstance(var, types): raise TypeError( - "Expected type for ``{}`` is {}" - " but {} was given.".format(var_name, str(types), type(var)) + f"Expected type for ``{var_name}`` is {str(types)}" + f" but {type(var)} was given." )