From e044c07cd6746198d5e73c15757d320b70b377f4 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 22 May 2021 18:41:57 +0200 Subject: [PATCH] Added isort config; linter now checks tests --- Makefile | 8 +++++--- app/__init__.py | 1 + app/exceptions.py | 2 +- app/skeleton.py | 1 + pyproject.toml | 4 ++++ setup.cfg | 1 + setup.py | 2 +- tests/__init__.py | 1 + tests/test_skeleton.py | 10 ++++------ 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index f59c731..1d0b397 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ PYTHON := python3 VENV := .venv # Minimum % coverage for tests to succeed MIN_COV := 50 +SRC := setup.py app tests # =====GENERAL===== @@ -33,13 +34,14 @@ venv: $(VENV)/bin/activate ## Formatting & linting ### Format the codebase using black format: venv - @ '$(VENV)'/bin/black setup.py app + @ '$(VENV)'/bin/black $(SRC) + @ '$(VENV)'/bin/isort $(SRC) .PHONY: format ### Lint using black & flake8 lint: venv - @ '$(VENV)'/bin/flake8 setup.py app - @ '$(VENV)'/bin/black --check setup.py app + @ '$(VENV)'/bin/flake8 $(SRC) + @ '$(VENV)'/bin/black --check $(SRC) .PHONY: lint diff --git a/app/__init__.py b/app/__init__.py index e69de29..ef4e454 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -0,0 +1 @@ +"""Main module for the app.""" diff --git a/app/exceptions.py b/app/exceptions.py index b82bad8..34ff26e 100644 --- a/app/exceptions.py +++ b/app/exceptions.py @@ -1,5 +1,5 @@ """Common exceptions raised by the program.""" -from typing import Union, List +from typing import List, Union class InvalidKeyError(Exception): diff --git a/app/skeleton.py b/app/skeleton.py index c12bd45..e591a5b 100644 --- a/app/skeleton.py +++ b/app/skeleton.py @@ -1,5 +1,6 @@ """Handles merging with the skeleton config.""" from typing import Dict + from .exceptions import InvalidKeyError, MissingKeyError diff --git a/pyproject.toml b/pyproject.toml index 46e8364..a973db2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,3 +4,7 @@ build-backend = "setuptools.build_meta" [tool.black] line-length = 79 + +[tool.isort] +profile = "black" +multi_line_output = 3 diff --git a/setup.cfg b/setup.cfg index 83fa01d..3748eb5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,7 @@ lint = flake8-docstrings==1.6.0 flake8-print==4.0.0 flake8-quotes==3.2.0 + isort==5.8.0 # Required for the developer develop = diff --git a/setup.py b/setup.py index 056ba45..576fa39 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ +"""Setup script for the package.""" import setuptools - setuptools.setup() diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..f464093 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Main testing module.""" diff --git a/tests/test_skeleton.py b/tests/test_skeleton.py index 9ade87e..a0d0128 100644 --- a/tests/test_skeleton.py +++ b/tests/test_skeleton.py @@ -1,15 +1,13 @@ """Tests wether the skeleton merge works.""" -from app.skeleton import merge_with_skeleton -from app.exceptions import InvalidKeyError, MissingKeyError import pytest +from app.exceptions import InvalidKeyError, MissingKeyError +from app.skeleton import merge_with_skeleton + def test_single_invalid_key(): """Tests wether an InvalidKeyError is correctly thrown for a single key.""" - data = { - "test": 1, - "test2": "test" - } + data = {"test": 1, "test2": "test"} skel = { "test": None, }