diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..bd44966 --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +max-line-length = 79 +select = F,E,W,B,B901,B902,B903 +exclude = .eggs,.git,.tox,nssm,obj,out,packages,pywin32,tests,swagger_client +ignore = E722,B001,W503,E203 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0cd98a8..46ee56e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,4 +22,18 @@ repos: rev: 23.1.0 hooks: - id: black - args: [--line-length, "79", --experimental-string-processing] + args: ["--config", "pyproject.toml"] + + # python import sorting + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + args: ["--settings-path", "pyproject.toml"] + + # python check (PEP8), programming errors and code complexity + - repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + args: ["--config", ".flake8"] diff --git a/.vscode/settings.json b/.vscode/settings.json index 6422f59..4785bc9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,7 +24,8 @@ "--config=pyproject.toml" ], "flake8.args": [ - "--toml-config=pyproject.toml" + "--config", + ".flake8" ], "isort.args": [ "--settings-path=pyproject.toml" diff --git a/nvcc4jupyter/__init__.py b/nvcc4jupyter/__init__.py index 33266ea..e9f7145 100644 --- a/nvcc4jupyter/__init__.py +++ b/nvcc4jupyter/__init__.py @@ -1,3 +1,3 @@ -from .plugin import NVCCPlugin, load_ipython_extension +from .plugin import NVCCPlugin, load_ipython_extension # noqa: F401 __version__ = "1.0.2" diff --git a/nvcc4jupyter/parsers.py b/nvcc4jupyter/parsers.py index 201aaf5..7679465 100644 --- a/nvcc4jupyter/parsers.py +++ b/nvcc4jupyter/parsers.py @@ -5,7 +5,7 @@ def get_parser_cuda() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( description=( "%%cuda magic that compiles and runs CUDA C++ code in this cell." - " See https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda" + " See https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda" # noqa: E501 " for usage details." ) ) @@ -20,7 +20,7 @@ def get_parser_cuda_group_run() -> argparse.ArgumentParser: parser.description = ( "%%cuda_group_run magic that compiles and runs source files in a given" " group. See" - " https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-run" + " https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-run" # noqa: E501 " for usage details." ) parser.add_argument("-g", "--group", type=str, required=True) @@ -32,7 +32,7 @@ def get_parser_cuda_group_save() -> argparse.ArgumentParser: description=( "%%cuda_group_save magic that saves CUDA C++ code in this cell for" " later compilation and execution with possibly more source files." - " See https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-save" + " See https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-save" # noqa: E501 " for usage details." ) ) @@ -45,7 +45,7 @@ def get_parser_cuda_group_delete() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( description=( "%%cuda_group_delete magic that deletes all files in a group. See" - " https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-delete" + " https://nvcc4jupyter.readthedocs.io/en/latest/magics.html#cuda-group-delete" # noqa: E501 " for usage details." ) ) diff --git a/nvcc4jupyter/plugin.py b/nvcc4jupyter/plugin.py index e278d56..a4ff704 100644 --- a/nvcc4jupyter/plugin.py +++ b/nvcc4jupyter/plugin.py @@ -17,8 +17,8 @@ SHARED_GROUP_NAME = "shared" def print_out(out: str): - for l in out.split("\n"): - print(l) + for line in out.split("\n"): + print(line) @magics_class diff --git a/pyproject.toml b/pyproject.toml index 2e5ca54..5f5e495 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,28 +85,6 @@ experimental-string-processing = true [tool.coverage.run] branch = true -[tool.flake8] -max-line-length = 79 -select = "F,E,W,B,B901,B902,B903" -exclude = [ - ".eggs", - ".git", - ".tox", - "nssm", - "obj", - "out", - "packages", - "pywin32", - "tests", - "swagger_client" -] -ignore = [ - "E722", - "B001", - "W503", - "E203" -] - [tool.pyright] include = ["src"] exclude = [ diff --git a/tests/conftest.py b/tests/conftest.py index 634fb8c..3bb2d59 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1 +1 @@ -from .fixtures.fixtures import * +from .fixtures.fixtures import * # noqa: F401,F403 diff --git a/tests/fixtures/fixtures.py b/tests/fixtures/fixtures.py index f97b086..93b88fb 100644 --- a/tests/fixtures/fixtures.py +++ b/tests/fixtures/fixtures.py @@ -30,7 +30,7 @@ def fixtures_path(tests_path): @pytest.fixture(scope="session") def sample_magic_cu_line(): # fmt: off - return '--profile --profiler-args "--metrics l1tex__t_sectors_pipe_lsu_mem_global_op_ld.sum"' + return '--profile --profiler-args "--metrics l1tex__t_sectors_pipe_lsu_mem_global_op_ld.sum"' # noqa: E501 # fmt: on