Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve setup and docs #239

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,41 @@ To set up `import-linter` for local development:

git clone [email protected]:your_name_here/import-linter.git

3. Setup venv::

virtualenv venv

# On macOS/Linux:
source venv/bin/activate
# On Windows:
.\venv\Scripts\activate

pip install -e .
pip install -r requirements-dev.txt

3. Create a branch for local development::

git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

4. When you're done making changes, run all the checks with `tox <https://tox.wiki/en/latest/installation.html>`_ one command::
4. Run tests/checks::

pytest
black src tests
flake8 src tests
mypy src tests
isort src tests
lint-imports

5. When you're done making changes, run all the checks with `tox <https://tox.wiki/en/latest/installation.html>`_ one command::

tox

5. Commit your changes and push your branch to GitHub::
6. Commit your changes and push your branch to GitHub::

git add .
git commit -m "Your detailed description of your changes."
git push origin name-of-your-bugfix-or-feature

6. Submit a pull request through the GitHub website.
7. Submit a pull request through the GitHub website.
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,29 @@ namespaces = false

[tool.black]
line-length = 99
extend-exclude = '''
/(
docs
|venv
|\.tox
)/
'''

[tool.isort]
profile = "black"
multi_line_output = 3
include_trailing_comma = "True"
force_grid_wrap = 0
use_parentheses = "True"
line_length = 99
skip = ["docs", "venv", ".tox"]

[tool.mypy]
exclude = [
'^tests/assets/',
'^docs/*',
'^venv/*',
'^\.tox/',
]
warn_unused_ignores = true
warn_redundant_casts = true
7 changes: 7 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PyYAML~=6.0.1
black~=22.3.0
flake8~=4.0.1
mypy~=0.730
pytest~=7.4.0
pytest-cov~=4.1.0
types-PyYAML
7 changes: 6 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[flake8]
ignore = E731, E203, W503
max-line-length = 100
exclude = */migrations/*, tests/assets/*
exclude =
*/migrations/*,
tests/assets/*,
.tox,
docs,
venv
4 changes: 2 additions & 2 deletions src/importlinter/adapters/user_options.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import configparser
from typing import Any, Dict, Optional, List
import abc
import configparser
import sys
from typing import Any, Dict, List, Optional

if sys.version_info >= (3, 11):
import tomllib
Expand Down
2 changes: 1 addition & 1 deletion src/importlinter/application/contract_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import enum
from typing import List, Optional, Sequence, Set

from grimp import ImportGraph

from importlinter.domain import helpers
from importlinter.domain.helpers import MissingImport
from importlinter.domain.imports import ImportExpression
from grimp import ImportGraph


class AlertLevel(enum.Enum):
Expand Down
3 changes: 2 additions & 1 deletion src/importlinter/application/ports/reporting.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Dict, Iterator, List, Tuple

from importlinter.domain.contract import Contract, ContractCheck, InvalidContractOptions
from grimp import ImportGraph

from importlinter.domain.contract import Contract, ContractCheck, InvalidContractOptions


class Reporter:
...
Expand Down
7 changes: 1 addition & 6 deletions src/importlinter/contracts/independence.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
from importlinter.domain.helpers import module_expressions_to_modules
from importlinter.domain.imports import Module

from ._common import (
DetailedChain,
Link,
build_detailed_chain_from_route,
render_chain_data,
)
from ._common import DetailedChain, Link, build_detailed_chain_from_route, render_chain_data


class _SubpackageChainData(TypedDict):
Expand Down
1 change: 0 additions & 1 deletion src/importlinter/contracts/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from ._common import DetailedChain, build_detailed_chain_from_route, render_chain_data


_INDEPENDENT_LAYER_DELIMITER = "|"
_NON_INDEPENDENT_LAYER_DELIMITER = ":"

Expand Down
7 changes: 1 addition & 6 deletions src/importlinter/domain/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

from grimp import DetailedImport, ImportGraph

from importlinter.domain.imports import (
DirectImport,
ImportExpression,
Module,
ModuleExpression,
)
from importlinter.domain.imports import DirectImport, ImportExpression, Module, ModuleExpression


class MissingImport(Exception):
Expand Down
1 change: 1 addition & 0 deletions tests/assets/multipleroots/rootpackageblue/one/alpha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys # Standard library import.

import pytest # Third party library import.

BAR = "bar"
1 change: 0 additions & 1 deletion tests/assets/testpackage/testpackage/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from pytest import mark

from testpackage.high import green
3 changes: 2 additions & 1 deletion tests/helpers/contracts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from grimp import ImportGraph

from importlinter.application import output
from importlinter.domain import fields
from importlinter.domain.contract import Contract, ContractCheck
from grimp import ImportGraph


class AlwaysPassesContract(Contract):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/contracts/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from importlinter.application.app_config import settings
from importlinter.contracts.layers import Layer, LayerField, LayersContract, ModuleTail
from importlinter.domain import fields
from importlinter.domain.contract import ContractCheck, InvalidContractOptions
from importlinter.domain.helpers import MissingImport
from importlinter.domain import fields
from tests.adapters.printing import FakePrinter
from tests.adapters.timing import FakeTimer

Expand Down
11 changes: 3 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,19 @@ passenv =
*
usedevelop = false
deps =
pytest~=7.4.0
pytest-cov~=4.1.0
PyYAML~=6.0.1
-r requirements-dev.txt
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer, thanks!

commands =
{posargs:pytest --cov --cov-report=term-missing -vv tests}


[testenv:check]
deps =
{[testenv]deps}
black~=22.3.0
flake8~=4.0.1
mypy~=0.730
types-PyYAML
commands =
black --check src tests
isort --check src tests
flake8 src tests
mypy src/importlinter tests
mypy src tests
lint-imports

[testenv:docs]
Expand Down
Loading