Skip to content

Commit

Permalink
Closes #720
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Jul 28, 2019
1 parent ae821dd commit 98d2286
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 38 deletions.
84 changes: 84 additions & 0 deletions .importlinter
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[importlinter]
root_package = wemake_python_styleguide
include_external_packages = True


[importlinter:contract:layers]
name = Layered architecture of our linter
type = layers

containers =
wemake_python_styleguide

layers =
checker
transformations
presets
visitors
violations
logic
compat
options
constants
types


# TODO: provide independence contract for visitors
[importlinter:contract:violation-independence]
name = Independence contract for violations (all shall be free!)
type = independence

modules =
wemake_python_styleguide.violations.naming
wemake_python_styleguide.violations.complexity
wemake_python_styleguide.violations.consistency
wemake_python_styleguide.violations.best_practices
wemake_python_styleguide.violations.refactoring
wemake_python_styleguide.violations.oop


[importlinter:contract:flake8-independence]
name = Independence contract for flake8 API (all shall be free!)
type = independence

modules =
wemake_python_styleguide.checker
wemake_python_styleguide.formatter


[importlinter:contract:api-restrictions]
name = Forbids to import anything from dependencies
type = forbidden

source_modules =
wemake_python_styleguide

forbidden_modules =
# Important direct and indirect dependencies:
flake8
pygments
isort
bandit
eradicate
pydocstyle
pycodestyle
mccabe
radon

ignore_imports =
# These modules must import from flake8 to provide required API:
wemake_python_styleguide.checker -> flake8
wemake_python_styleguide.formatter -> flake8
wemake_python_styleguide.formatter -> pygments
wemake_python_styleguide.options.config -> flake8


[importlinter:contract:tests-restrictions]
name = Explicit import restrictions for tests
type = forbidden

source_modules =
wemake_python_styleguide

forbidden_modules =
tests
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ These steps are mandatory during the CI.

## Architecture

We use [layer-lint](https://layer-linter.readthedocs.io/en/latest/usage.html)
We use [import-linter](https://import-linter.readthedocs.io)
to enforce strict layered architecture.

```bash
layer-lint wemake_python_styleguide
lint-imports
```

See `.importlinter` file for contracts definition.
All contracts must be valid for each commit.
This step is mandatory during the CI.

Expand Down Expand Up @@ -141,7 +142,7 @@ Before submitting your code please do the following steps:
7. Run `pytest` again to make sure it is still working
8. Run `mypy` to ensure that types are correct
9. Run `flake8` to ensure that style is correct
10. Run `layer-lint` to ensure that architecture contracts are correct
10. Run `lint-imports` to ensure that architecture contracts are correct
11. Run `doc8` to ensure that docs are correct
12. Run `xenon` to ensure that code quality is `A` (good enough)

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lint:
flake8 .
autopep8 -r . --diff --exclude=./tests/fixtures/** --exit-code
xenon --max-absolute B --max-modules A --max-average A wemake_python_styleguide
layer-lint --quiet wemake_python_styleguide
lint-imports
poetry run doc8 -q docs

.PHONY: unit
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ to understand how all components are bound together.
We use a `layered architecture <https://layer-linter.readthedocs.io/en/stable/concepts.html>`_
that follows this contract:

.. literalinclude :: ../../../layers.yml
:language: yaml
.. literalinclude :: ../../../.importlinter
:language: ini
Contributing
------------
Expand Down
14 changes: 0 additions & 14 deletions layers.yml

This file was deleted.

45 changes: 28 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ m2r = "^0.2"
added-value = "^0.14"
tomlkit = "^0.5"
safety = "^1.8"
layer-linter = "^0.12.3"
autopep8 = "^1.4"
xenon = "^0.5.5"
import-linter = {version = "1.0b4", allows-prereleases = true}

0 comments on commit 98d2286

Please sign in to comment.