Skip to content

Commit

Permalink
DX: switch to new VSCode Python extensions (#469)
Browse files Browse the repository at this point in the history
* DX: activate and configure VSCode flake8 extension
* DX: activate and configure VSCode isort extension
* DX: activate and configure VSCode pylint extension
* DX: extend pyright file exclusions
* MAINT: limit scope of pyright ignore statements
  • Loading branch information
redeboer authored Nov 6, 2022
1 parent 816e7e0 commit 340004b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ vscode:
- esbenp.prettier-vscode
- executablebookproject.myst-highlight
- github.vscode-pull-request-github
- ms-python.flake8
- ms-python.pylint
- ms-python.isort
- ms-python.python
- ms-python.vscode-pylance
- ms-vsliveshare.vsliveshare
Expand Down
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"esbenp.prettier-vscode",
"executablebookproject.myst-highlight",
"github.vscode-pull-request-github",
"ms-python.flake8",
"ms-python.pylint",
"ms-python.isort",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vsliveshare.vsliveshare",
Expand Down
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@
"**/.git/**": true,
"**/.tox/**": true
},
"flake8.importStrategy": "fromEnvironment",
"git.rebaseWhenSync": true,
"github-actions.workflows.pinned.refresh.enabled": true,
"github-actions.workflows.pinned.workflows": [
".github/workflows/linkcheck.yml",
".github/workflows/ci-docs.yml",
".github/workflows/ci-tests.yml"
],
"isort.check": true,
"isort.importStrategy": "fromEnvironment",
"json.schemas": [
{
"fileMatch": ["*particle*.json"],
Expand All @@ -53,18 +56,18 @@
"url": "https://zenodo.org/schemas/deposits/records/legacyrecord.json"
}
],
"pylint.importStrategy": "fromEnvironment",
"python.analysis.autoImportCompletions": false,
"python.analysis.diagnosticMode": "workspace",
"python.analysis.typeCheckingMode": "strict",
"python.formatting.provider": "black",
"python.linting.banditEnabled": false,
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Enabled": false,
"python.linting.mypyEnabled": true,
"python.linting.pydocstyleEnabled": true,
"python.linting.pylamaEnabled": false,
"python.linting.pylintCategorySeverity.refactor": "Information",
"python.linting.pylintEnabled": true,
"python.linting.pylintEnabled": false,
"python.testing.pytestArgs": ["--color=no", "--no-cov"],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
Expand Down
11 changes: 9 additions & 2 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"exclude": [".git", ".tox", "docs/_build"],
"include": ["docs", "src", "tests"],
"exclude": [
"**/__pycache__",
"**/_build",
"**/.git",
"**/.ipynb_checkpoints",
"**/.mypy_cache",
"**/.pytest_cache",
"**/.tox"
],
"reportGeneralTypeIssues": false,
"reportMissingTypeArgument": false,
"reportMissingTypeStubs": false,
Expand Down
6 changes: 3 additions & 3 deletions src/tensorwaves/function/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ def get_backend_modules(backend: str | tuple | dict) -> str | tuple | dict:
if backend in {"tensorflow", "tf"}:
try:
# pylint: disable=import-error, no-name-in-module
# pyright: reportMissingImports=false
import tensorflow as tf
import tensorflow.experimental.numpy as tnp
import tensorflow.experimental.numpy as tnp # pyright: ignore[reportMissingImports]
from tensorflow.python.ops.numpy_ops import np_config
except ImportError: # pragma: no cover
raise_missing_module_error("tensorflow", extras_require="tf")
Expand All @@ -75,7 +74,8 @@ def jit_compile(backend: str) -> Callable[[Callable], Callable]:

if backend == "numba":
try:
import numba # pylint: disable=import-error
# pylint: disable=import-error
import numba # pyright: ignore[reportMissingImports]
except ImportError: # pragma: no cover
raise_missing_module_error("numba", extras_require="numba")
return partial(numba.jit, forceobj=True, parallel=True)
Expand Down
3 changes: 1 addition & 2 deletions src/tensorwaves/function/sympy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ def numba_lambdify() -> Callable:
def tensorflow_lambdify() -> Callable:
try:
# pylint: disable=import-error
# pyright: reportMissingImports=false
import tensorflow.experimental.numpy as tnp
import tensorflow.experimental.numpy as tnp # pyright: ignore[reportMissingImports]
except ImportError: # pragma: no cover
raise_missing_module_error("tensorflow", extras_require="tf")
from ._printer import TensorflowPrinter
Expand Down
3 changes: 1 addition & 2 deletions tests/function/test_backend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# pylint: disable=import-error, import-outside-toplevel
# pyright: reportMissingImports=false
from tensorwaves.function._backend import find_function


Expand All @@ -23,7 +22,7 @@ def test_find_function_numpy():

def test_find_function_tf():
import tensorflow as tf
import tensorflow.experimental.numpy as tnp
import tensorflow.experimental.numpy as tnp # pyright: ignore[reportMissingImports]

assert find_function("array", backend="tf") is tnp.array
assert find_function("linspace", backend="tf") is tnp.linspace
Expand Down
3 changes: 1 addition & 2 deletions tests/optimizer/test_fit_simple_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ def test_optimize_all_parameters( # pylint: disable=too-many-locals
]
try:
# pylint: disable=import-outside-toplevel
# pyright: reportUnusedImport=false
import tensorflow # noqa: F401
import tensorflow # pyright: ignore[reportUnusedImport] # noqa: F401

callbacks.append(TFSummary())
except ImportError:
Expand Down

0 comments on commit 340004b

Please sign in to comment.