Skip to content

Commit

Permalink
🚚 Move configuration from tox to pyproject (#458)
Browse files Browse the repository at this point in the history
* Moved configuration from tox to pyproject

* Format the pyproject.toml file

* Format the pyproject.toml file

Co-authored-by: someone <someone@example.com>
  • Loading branch information
samet-akcay and someone committed Jul 28, 2022
1 parent 7a21fa6 commit d0fcad3
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 67 deletions.
10 changes: 4 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ repos:
rev: 22.6.0
hooks:
- id: black
args: [--line-length, "120"]

# python import sorting
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black"]

# yaml formatting
- repo: https://github.com/pre-commit/mirrors-prettier
Expand All @@ -36,7 +34,7 @@ repos:
rev: 4.0.1
hooks:
- id: flake8
args: [--config=tox.ini]
args: ["--max-line-length=120", "--ignore=E203,W503"]
exclude: "tests|anomalib/models/components/freia"

# python linting
Expand All @@ -45,7 +43,7 @@ repos:
hooks:
- id: pylint
name: pylint
entry: pylint --score=no --rcfile=tox.ini
entry: pylint --score=no
language: system
types: [python]
exclude: "tests|docs|anomalib/models/components/freia"
Expand All @@ -55,19 +53,18 @@ repos:
rev: "v0.971"
hooks:
- id: mypy
args: [--config-file=tox.ini]
additional_dependencies: [types-PyYAML]
exclude: "tests|anomalib/models/components/freia"

- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
additional_dependencies: [toml]
name: pydocstyle
entry: pydocstyle
language: python
types: [python]
args: [--config=tox.ini]
exclude: "tests|docs|anomalib/models/components/freia"

# notebooks.
Expand All @@ -77,4 +74,5 @@ repos:
- id: nbqa-black
- id: nbqa-isort
- id: nbqa-flake8
args: ["--max-line-length=120", "--ignore=E203,W503"]
- id: nbqa-pylint
99 changes: 96 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,109 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# SETUP CONFIGURATION. #
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# ISORT CONFIGURATION. #
[tool.isort]
profile = "black"
known_first_party = "wandb"
sections = ['FUTURE', 'STDLIB', 'THIRDPARTY', 'FIRSTPARTY', 'LOCALFOLDER']


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# BLACK CONFIGURATION #
[tool.black]
line-length = 120

[tool.nbqa.addopts]
pylint = [
"--disable=C0103,C0114,C0116,E0401,R0801,W0106"
[tool.flake8]
ignore = ["E203", "W503"]
max-line-length = 120


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# PYLINT CONFIGURATION #
[tool.pylint.main]
extension-pkg-whitelist = "cv2"
ignore = ["tests", "docs", "anomalib/models/components/freia"]
ignored-modules = "cv2"

[tool.pylint.messages_control]
disable = [
"duplicate-code",
"arguments-differ",
"fixme",
"import-error",
"too-many-arguments",
"too-many-branches",
"too-many-instance-attributes",
"too-many-locals",
"too-few-public-methods",
]

[tool.pylint.typecheck]
generated-members = ["numpy.*", "torch.*"]

[tool.pylint.basic]
good-names = ["e", "i", "id"]

[tool.pylint.format]
max-line-length = 120

[tool.pylint.design]
max-parents = 15

[tool.pylint.similarities]
min-similarity-lines = 5


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# MYPY CONFIGURATION. #
[tool.mypy]
ignore_missing_imports = true
show_error_codes = true
exclude = ["anomalib/models/components/freia/"]

# mypy per-module options:
[[tool.mypy.overrides]]
module = "anomalib.models.components.freia.*"
follow_imports = "skip"

[[tool.mypy.overrides]]
module = "torch.*"
follow_imports = "skip"
follow_imports_for_stubs = true


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# COVERAGE CONFIGURATION #
[tool.coverage.report]
exclude_lines = [
"except ImportError",
"raise ImportError",
"except ApiException",
"raise ApiException",
"raise ValueError",
]

[tool.pydocstyle]
inherit = false
ignore = [
"D107", # Missing docstring in __init__
"D202", # No blank lines allowed after function docstring
"D203", # 1 blank line required before class docstring
"D213", # Multi-line docstring summary should start at the second line
"D401", # First line should be in imperative mood; try rephrasing
"D404", # First word of the docstring should not be This
"D406", # Section name should end with a newline
"D407", # Missing dashed underline after section
"D413", # Missing blank line after last section
]


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# NBQA CONFIGURATION #
[tool.nbqa.addopts]
pylint = ["--disable=C0103,C0114,C0116,E0401,R0801,W0106"]
59 changes: 1 addition & 58 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ passenv = ftp_proxy
CUDA_VISIBLE_DEVICES
ANOMALIB_DATASET_PATH
deps =
coverage
coverage[toml]
pytest
flaky
-r{toxinidir}/requirements/base.txt
Expand Down Expand Up @@ -50,60 +50,3 @@ commands =
; https://github.com/openvinotoolkit/anomalib/issues/94
coverage report -m --fail-under=33
coverage xml -o {toxworkdir}/coverage.xml

[flake8]
max-line-length = 120
ignore = E203,W503

[pylint]
extension-pkg-whitelist = cv2
ignored-modules = cv2
disable = duplicate-code,
arguments-differ,
fixme,
import-error,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-locals,
too-few-public-methods,

generated-members = numpy.*, torch.*
good-names = e, i, id
ignore = tests,docs,anomalib/models/components/freia

max-line-length = 120
max-parents = 15
min-similarity-lines = 5


[mypy]
ignore_missing_imports = True
show_error_codes = True
exclude = anomalib/models/components/freia/
[mypy-anomalib.models.components.freia.*]
follow_imports = skip
[mypy-torch.*]
follow_imports = skip
follow_imports_for_stubs = True


[coverage:report]
exclude_lines =
except ImportError
raise ImportError
except ApiException
raise ApiException
raise ValueError

[pydocstyle]
inherit = false
ignore = D107, ; Missing docstring in __init__
D202, ; No blank lines allowed after function docstring
D203, ; 1 blank line required before class docstring
D213, ; Multi-line docstring summary should start at the second line
D401, ; First line should be in imperative mood; try rephrasing
D404, ; First word of the docstring should not be This
D406, ; Section name should end with a newline
D407, ; Missing dashed underline after section
D413 ; Missing blank line after last section

0 comments on commit d0fcad3

Please sign in to comment.