From 5645e8296fdd48dd4a97e96074c904cb89008e2d Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Fri, 1 Dec 2023 10:21:31 -0500 Subject: [PATCH 01/11] feat: init pre-commit settings via poetry --- .pre-commit-config.yaml | 18 ++++++ chasten/checks.py | 11 +++- chasten/configApp.py | 11 +++- chasten/configuration.py | 21 ++++--- chasten/database.py | 6 +- chasten/filesystem.py | 13 ++++- chasten/main.py | 35 ++++++------ chasten/output.py | 10 +++- chasten/process.py | 9 ++- chasten/results.py | 4 +- chasten/server.py | 3 +- chasten/validate.py | 9 ++- poetry.lock | 109 +++++++++++++++++++++++++++++++++++- pyproject.toml | 2 + tests/test_checks.py | 12 ++-- tests/test_configApp.py | 7 ++- tests/test_configuration.py | 3 +- tests/test_constants.py | 3 +- tests/test_createchecks.py | 3 +- tests/test_debug.py | 3 +- tests/test_filesystem.py | 6 +- tests/test_main.py | 5 +- tests/test_util.py | 6 +- tests/test_validate.py | 8 ++- 24 files changed, 253 insertions(+), 64 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..b585fe04 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +# configuring pre-commit hooks for chasten. +# this ensures users do not commit problematic code +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-ast + - id: check-case-conflict + - id: check-merge-conflict + - id: forbid-submodules + - id: trailing-whitespace + + - repo: local + hooks: + - id: fix-imports + name: Fix Imports + entry: poetry run task fiximports + language: system diff --git a/chasten/checks.py b/chasten/checks.py index 6e1d2b54..c732f6c0 100644 --- a/chasten/checks.py +++ b/chasten/checks.py @@ -1,8 +1,13 @@ """Extract and analyze details about specific checks.""" -from typing import Dict, List, Tuple, Union - -from chasten import constants, enumerations, util +from typing import Dict +from typing import List +from typing import Tuple +from typing import Union + +from chasten import constants +from chasten import enumerations +from chasten import util def extract_min_max( diff --git a/chasten/configApp.py b/chasten/configApp.py index 2177f785..3b8d8d24 100644 --- a/chasten/configApp.py +++ b/chasten/configApp.py @@ -1,11 +1,16 @@ # Import necessary modules and components from the Textual library, # as well as other Python modules like os and validation tools. from pathlib import Path -from typing import ClassVar, List +from typing import ClassVar +from typing import List -from textual.app import App, ComposeResult +from textual.app import App +from textual.app import ComposeResult from textual.validation import Number -from textual.widgets import Button, Input, Pretty, Static +from textual.widgets import Button +from textual.widgets import Input +from textual.widgets import Pretty +from textual.widgets import Static from chasten import constants diff --git a/chasten/configuration.py b/chasten/configuration.py index d3c79033..d0130953 100644 --- a/chasten/configuration.py +++ b/chasten/configuration.py @@ -5,22 +5,25 @@ import logging.handlers import sys from pathlib import Path -from typing import Any, Dict, List, Tuple, Union +from typing import Any +from typing import Dict +from typing import List +from typing import Tuple +from typing import Union import platformdirs import requests import yaml from rich.logging import RichHandler from rich.traceback import install -from urllib3.util import Url, parse_url +from urllib3.util import Url +from urllib3.util import parse_url -from chasten import ( - constants, - filesystem, - output, - util, - validate, -) +from chasten import constants +from chasten import filesystem +from chasten import output +from chasten import util +from chasten import validate def configure_tracebacks() -> None: diff --git a/chasten/database.py b/chasten/database.py index fa28f7e5..2bab1673 100644 --- a/chasten/database.py +++ b/chasten/database.py @@ -6,7 +6,11 @@ from sqlite_utils import Database -from chasten import constants, enumerations, filesystem, output, util +from chasten import constants +from chasten import enumerations +from chasten import filesystem +from chasten import output +from chasten import util CHASTEN_SQL_SELECT_QUERY = """ SELECT diff --git a/chasten/filesystem.py b/chasten/filesystem.py index 28a3e8bb..33c2bfc5 100644 --- a/chasten/filesystem.py +++ b/chasten/filesystem.py @@ -5,12 +5,21 @@ import uuid from datetime import datetime from pathlib import Path -from typing import Any, Dict, List, NoReturn, Optional, Tuple, Union +from typing import Any +from typing import Dict +from typing import List +from typing import NoReturn +from typing import Optional +from typing import Tuple +from typing import Union import flatterer # type: ignore from rich.tree import Tree -from chasten import configuration, constants, database, results +from chasten import configuration +from chasten import constants +from chasten import database +from chasten import results CONFIGURATION_FILE_DEFAULT_CONTENTS = """ # chasten configuration diff --git a/chasten/main.py b/chasten/main.py index 309e462c..ec5dc3dd 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -4,27 +4,28 @@ import sys import time from pathlib import Path -from typing import Dict, List, Tuple, Union +from typing import Dict +from typing import List +from typing import Tuple +from typing import Union import typer from pyastgrep import search as pyastgrepsearch # type: ignore -from chasten import ( - checks, - configApp, - configuration, - constants, - createchecks, - database, - debug, - enumerations, - filesystem, - output, - process, - results, - server, - util, -) +from chasten import checks +from chasten import configApp +from chasten import configuration +from chasten import constants +from chasten import createchecks +from chasten import database +from chasten import debug +from chasten import enumerations +from chasten import filesystem +from chasten import output +from chasten import process +from chasten import results +from chasten import server +from chasten import util # create a Typer object to support the command-line interface cli = typer.Typer(no_args_is_help=True) diff --git a/chasten/output.py b/chasten/output.py index bfa8bb0d..c0bc78ac 100644 --- a/chasten/output.py +++ b/chasten/output.py @@ -3,14 +3,20 @@ import logging from copy import deepcopy from pathlib import Path -from typing import Any, Dict, List +from typing import Any +from typing import Dict +from typing import List from pyastgrep import search as pyastgrepsearch # type: ignore from rich.console import Console from rich.panel import Panel from rich.syntax import Syntax -from chasten import checks, configuration, constants, debug, results +from chasten import checks +from chasten import configuration +from chasten import constants +from chasten import debug +from chasten import results # declare a default logger logger: logging.Logger = logging.getLogger() diff --git a/chasten/process.py b/chasten/process.py index 5670b4e1..a701c059 100644 --- a/chasten/process.py +++ b/chasten/process.py @@ -1,12 +1,17 @@ """Analyze the abstract syntax tree, its XML-based representation, and/or the search results.""" import json -from typing import Any, Dict, List, Tuple, Union +from typing import Any +from typing import Dict +from typing import List +from typing import Tuple +from typing import Union from pyastgrep import search as pyastgrepsearch # type: ignore from thefuzz import fuzz # type: ignore -from chasten import constants, enumerations +from chasten import constants +from chasten import enumerations def include_or_exclude_checks( diff --git a/chasten/results.py b/chasten/results.py index d56b9101..7b9fd95e 100644 --- a/chasten/results.py +++ b/chasten/results.py @@ -3,7 +3,9 @@ import uuid from datetime import datetime from pathlib import Path -from typing import List, Optional, Union +from typing import List +from typing import Optional +from typing import Union from pyastgrep import search as pyastgrepsearch # type: ignore from pydantic import BaseModel diff --git a/chasten/server.py b/chasten/server.py index acf75116..e6e813d5 100644 --- a/chasten/server.py +++ b/chasten/server.py @@ -4,7 +4,8 @@ import logging.handlers import socketserver -from chasten import constants, output +from chasten import constants +from chasten import output LOG_FILE = constants.server.Log_File HOST = constants.server.Localhost diff --git a/chasten/validate.py b/chasten/validate.py index 1b25e0a9..bca221c8 100644 --- a/chasten/validate.py +++ b/chasten/validate.py @@ -1,11 +1,16 @@ """Validate various aspects of configurations and command-line arguments.""" -from typing import Any, Dict, List, Tuple +from typing import Any +from typing import Dict +from typing import List +from typing import Tuple import jsonschema from jsonschema.exceptions import ValidationError -from chasten import constants, output, util +from chasten import constants +from chasten import output +from chasten import util # intuitive description: # a configuration file links to one or more checks files diff --git a/poetry.lock b/poetry.lock index 2b35cccd..21925411 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "aiofiles" @@ -275,6 +275,7 @@ files = [ {file = "black-23.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5133f5507007ba08d8b7b263c7aa0f931af5ba88a29beacc4b2dc23fcefe9c06"}, {file = "black-23.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:421f3e44aa67138ab1b9bfbc22ee3780b22fa5b291e4db8ab7eee95200726b07"}, {file = "black-23.11.0-py3-none-any.whl", hash = "sha256:54caaa703227c6e0c87b76326d0862184729a69b73d3b7305b6288e1d830067e"}, + {file = "black-23.11.0.tar.gz", hash = "sha256:4c68855825ff432d197229846f971bc4d6666ce90492e5b02013bcaca4d9ab05"}, ] [package.dependencies] @@ -376,6 +377,17 @@ files = [ [package.dependencies] pycparser = "*" +[[package]] +name = "cfgv" +version = "3.4.0" +description = "Validate configuration and produce human readable error messages." +optional = false +python-versions = ">=3.8" +files = [ + {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, + {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, +] + [[package]] name = "charset-normalizer" version = "3.3.2" @@ -842,6 +854,17 @@ sqlite-regex = "*" [package.extras] test = ["pytest"] +[[package]] +name = "distlib" +version = "0.3.7" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.7-py2.py3-none-any.whl", hash = "sha256:2e24928bc811348f0feb63014e97aaae3037f2cf48712d51ae61df7fd6075057"}, + {file = "distlib-0.3.7.tar.gz", hash = "sha256:9dafe54b34a028eafd95039d5e5d4851a13734540f1331060d31c9916e7147a8"}, +] + [[package]] name = "elementpath" version = "4.1.5" @@ -870,6 +893,22 @@ files = [ [package.extras] testing = ["hatch", "pre-commit", "pytest", "tox"] +[[package]] +name = "filelock" +version = "3.13.1" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.8" +files = [ + {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, + {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +typing = ["typing-extensions (>=4.8)"] + [[package]] name = "flask" version = "3.0.0" @@ -1167,6 +1206,20 @@ files = [ hypothesis = ">=6.31.6" jsonschema = ">=4.0.0" +[[package]] +name = "identify" +version = "2.5.32" +description = "File identification library for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "identify-2.5.32-py2.py3-none-any.whl", hash = "sha256:0b7656ef6cba81664b783352c73f8c24b39cf82f926f78f4550eda928e5e0545"}, + {file = "identify-2.5.32.tar.gz", hash = "sha256:5d9979348ec1a21c768ae07e0a652924538e8bce67313a73cb0f681cf08ba407"}, +] + +[package.extras] +license = ["ukkonen"] + [[package]] name = "idna" version = "3.4" @@ -1987,6 +2040,20 @@ files = [ {file = "nest_asyncio-1.5.8.tar.gz", hash = "sha256:25aa2ca0d2a5b5531956b9e273b45cf664cae2b145101d73b86b199978d48fdb"}, ] +[[package]] +name = "nodeenv" +version = "1.8.0" +description = "Node.js virtual environment builder" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +files = [ + {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, + {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, +] + +[package.dependencies] +setuptools = "*" + [[package]] name = "numpy" version = "1.26.2" @@ -2293,6 +2360,24 @@ files = [ {file = "pprintpp-0.4.0.tar.gz", hash = "sha256:ea826108e2c7f49dc6d66c752973c3fc9749142a798d6b254e1e301cfdbc6403"}, ] +[[package]] +name = "pre-commit" +version = "3.5.0" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +optional = false +python-versions = ">=3.8" +files = [ + {file = "pre_commit-3.5.0-py2.py3-none-any.whl", hash = "sha256:841dc9aef25daba9a0238cd27984041fa0467b4199fc4852e27950664919f660"}, + {file = "pre_commit-3.5.0.tar.gz", hash = "sha256:5804465c675b659b0862f07907f96295d490822a450c4c40e747d0b1c6ebcb32"}, +] + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +virtualenv = ">=20.10.0" + [[package]] name = "psutil" version = "5.9.6" @@ -3442,6 +3527,26 @@ h11 = ">=0.8" [package.extras] standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1)", "watchfiles (>=0.13)", "websockets (>=10.4)"] +[[package]] +name = "virtualenv" +version = "20.24.7" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.7" +files = [ + {file = "virtualenv-20.24.7-py3-none-any.whl", hash = "sha256:a18b3fd0314ca59a2e9f4b556819ed07183b3e9a3702ecfe213f593d44f7b3fd"}, + {file = "virtualenv-20.24.7.tar.gz", hash = "sha256:69050ffb42419c91f6c1284a7b24e0475d793447e35929b488bf6a0aade39353"}, +] + +[package.dependencies] +distlib = ">=0.3.7,<1" +filelock = ">=3.12.2,<4" +platformdirs = ">=3.9.1,<5" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] + [[package]] name = "werkzeug" version = "3.0.1" @@ -3575,4 +3680,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "919229c283aae8adf17519b2722864f93f07b41cee22c9cced339ef555027dd0" +content-hash = "25211477e5ff090ff973ffb08bccd8400a813fb4bf1141756214a9e544313170" diff --git a/pyproject.toml b/pyproject.toml index bb7654a6..7ab2d74a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,7 @@ types-pyyaml = "^6.0.12.10" types-jsonschema = "^4.17.0.9" types-requests = "^2.31.0.10" hypothesis-jsonschema = "^0.22.1" +pre-commit = "^3.5.0" pytest-clarity = "^1.0.1" pytest-randomly = "^3.13.0" pytest-pretty = "^1.2.0" @@ -119,6 +120,7 @@ test-api = { cmd = "{openai-test}", help = "Run openai powered test cases", use_ not-openai-test = { cmd = "{not-openai-test}", help = "Run openai powered test cases", use_vars = true } test-coverage = { cmd = "{coverage-test-command}", help = "Run coverage monitoring for the test suite", use_vars = true } test-coverage-silent = { cmd = "{coverage-test-command-silent}", help = "Run coverage monitoring for tests without output", use_vars = true } +pre-commit-install = { cmd = "pre-commit install", help = "Install or update pre-commit hooks" } [build-system] requires = ["poetry-core"] diff --git a/tests/test_checks.py b/tests/test_checks.py index 9c1dd093..893b130d 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -2,14 +2,14 @@ import hypothesis.strategies as st import pytest -from hypothesis import HealthCheck, given, settings +from hypothesis import HealthCheck +from hypothesis import given +from hypothesis import settings from hypothesis_jsonschema import from_schema -from chasten.checks import ( - check_match_count, - extract_min_max, - is_in_closed_interval, -) +from chasten.checks import check_match_count +from chasten.checks import extract_min_max +from chasten.checks import is_in_closed_interval from chasten.validate import JSON_SCHEMA_CHECKS JSON_SCHEMA_COUNT = { diff --git a/tests/test_configApp.py b/tests/test_configApp.py index 9850774f..854219b9 100644 --- a/tests/test_configApp.py +++ b/tests/test_configApp.py @@ -1,10 +1,13 @@ import pathlib import pytest -from hypothesis import HealthCheck, given, settings +from hypothesis import HealthCheck +from hypothesis import given +from hypothesis import settings from hypothesis import strategies as st -from chasten import configApp, constants +from chasten import configApp +from chasten import constants # Define an alphabet of characters for generating random test data ALPHABET = "0123456789!@#$%^&*()_+-=[]|:;'<>.?/~`AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz" diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 739572a4..184dd0fe 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -3,7 +3,8 @@ import logging import pytest -from hypothesis import given, strategies +from hypothesis import given +from hypothesis import strategies from chasten import configuration diff --git a/tests/test_constants.py b/tests/test_constants.py index b914e588..5c119dd7 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -4,7 +4,8 @@ from pathlib import Path import pytest -from hypothesis import given, strategies +from hypothesis import given +from hypothesis import strategies from chasten import constants diff --git a/tests/test_createchecks.py b/tests/test_createchecks.py index 9a924fca..27219405 100644 --- a/tests/test_createchecks.py +++ b/tests/test_createchecks.py @@ -3,7 +3,8 @@ import pytest -from chasten.createchecks import generate_yaml_config, is_valid_api_key +from chasten.createchecks import generate_yaml_config +from chasten.createchecks import is_valid_api_key def get_valid_api_key(): diff --git a/tests/test_debug.py b/tests/test_debug.py index 0303ea8d..e486f86d 100644 --- a/tests/test_debug.py +++ b/tests/test_debug.py @@ -2,7 +2,8 @@ import pytest -from chasten.debug import DebugDestination, DebugLevel +from chasten.debug import DebugDestination +from chasten.debug import DebugLevel def test_debug_level_values(): diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py index ac3289f3..17c06438 100644 --- a/tests/test_filesystem.py +++ b/tests/test_filesystem.py @@ -5,10 +5,12 @@ from unittest.mock import patch import pytest -from hypothesis import given, strategies +from hypothesis import given +from hypothesis import strategies from rich.tree import Tree -from chasten import constants, filesystem +from chasten import constants +from chasten import filesystem def test_valid_directory() -> None: diff --git a/tests/test_main.py b/tests/test_main.py index 65369ed5..8f43a1d0 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -5,7 +5,10 @@ from unittest.mock import patch import pytest -from hypothesis import HealthCheck, given, settings, strategies +from hypothesis import HealthCheck +from hypothesis import given +from hypothesis import settings +from hypothesis import strategies from typer.testing import CliRunner from chasten import main diff --git a/tests/test_util.py b/tests/test_util.py index 7ed69a7c..c411d38d 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -3,10 +3,12 @@ import shutil import pytest -from hypothesis import given, provisional +from hypothesis import given +from hypothesis import provisional from hypothesis import strategies as st -from chasten import constants, util +from chasten import constants +from chasten import util def test_human_readable_boolean() -> None: diff --git a/tests/test_validate.py b/tests/test_validate.py index 87845f23..6625a401 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -1,10 +1,14 @@ """Pytest test suite for the validate module.""" import pytest -from hypothesis import HealthCheck, given, settings, strategies +from hypothesis import HealthCheck +from hypothesis import given +from hypothesis import settings +from hypothesis import strategies from hypothesis_jsonschema import from_schema -from chasten.validate import JSON_SCHEMA_CONFIG, validate_configuration +from chasten.validate import JSON_SCHEMA_CONFIG +from chasten.validate import validate_configuration def test_validate_config_valid_realistic(): From 1090e48f11201d44946419921c97673fdd9f8fea Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Fri, 1 Dec 2023 11:33:43 -0500 Subject: [PATCH 02/11] total nonsense --- deleteme | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 deleteme diff --git a/deleteme b/deleteme new file mode 100644 index 00000000..e69de29b From 9940687c5190454b9644b302939df6e5ebde368d Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Fri, 1 Dec 2023 11:41:33 -0500 Subject: [PATCH 03/11] doc: contribution guidelines on commit hooks --- CONTRIBUTING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 53df7809..e1a2ebaf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,6 +28,21 @@ If the issue already exists, share any helpful information that you have gained Any changes being made to our program must first be done in a branch or fork. Once you (and your fellow contributors) are done making changes, you may create a pull request (PR) to the [main repository](https://github.com/AstuteSource/chasten). +### Pre-Commit Hooks + +Enabling pre-commit hooks on your system will save you from accidentally making +unwanted changes, such as incorrect formatting, committing merge conflicts, etc. + +You can enable pre-commit hooks after installing `poetry`: + +```sh +poetry install +poetry run task pre-commit-install # this sets up pre-commit hooks +``` + +Now, when you make commits, our specific checks will run. This will give you +greater confidence that your contributions align with our standards! + ### Branches Branches are one of the possible features of GitHub that you could use to make changes to our project. Learn about branches [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches). From 7e9182200f23ce6826b30b6d8496c87dcf9f75ed Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 5 Dec 2023 14:44:10 -0500 Subject: [PATCH 04/11] fix: removing temporary file --- deleteme | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 deleteme diff --git a/deleteme b/deleteme deleted file mode 100644 index e69de29b..00000000 From d1d0649d22d75e41330da9eac0c7fef9eccaef76 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 5 Dec 2023 19:29:59 -0500 Subject: [PATCH 05/11] feat: updating ruff --- poetry.lock | 40 ++++++++++++++++++++-------------------- pyproject.toml | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/poetry.lock b/poetry.lock index 21925411..56843bad 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3075,28 +3075,28 @@ files = [ [[package]] name = "ruff" -version = "0.0.277" -description = "An extremely fast Python linter, written in Rust." +version = "0.1.7" +description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.0.277-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:3250b24333ef419b7a232080d9724ccc4d2da1dbbe4ce85c4caa2290d83200f8"}, - {file = "ruff-0.0.277-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:3e60605e07482183ba1c1b7237eca827bd6cbd3535fe8a4ede28cbe2a323cb97"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7baa97c3d7186e5ed4d5d4f6834d759a27e56cf7d5874b98c507335f0ad5aadb"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:74e4b206cb24f2e98a615f87dbe0bde18105217cbcc8eb785bb05a644855ba50"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:479864a3ccd8a6a20a37a6e7577bdc2406868ee80b1e65605478ad3b8eb2ba0b"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:468bfb0a7567443cec3d03cf408d6f562b52f30c3c29df19927f1e0e13a40cd7"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f32ec416c24542ca2f9cc8c8b65b84560530d338aaf247a4a78e74b99cd476b4"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:14a7b2f00f149c5a295f188a643ac25226ff8a4d08f7a62b1d4b0a1dc9f9b85c"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9879f59f763cc5628aa01c31ad256a0f4dc61a29355c7315b83c2a5aac932b5"}, - {file = "ruff-0.0.277-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f612e0a14b3d145d90eb6ead990064e22f6f27281d847237560b4e10bf2251f3"}, - {file = "ruff-0.0.277-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:323b674c98078be9aaded5b8b51c0d9c424486566fb6ec18439b496ce79e5998"}, - {file = "ruff-0.0.277-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3a43fbe026ca1a2a8c45aa0d600a0116bec4dfa6f8bf0c3b871ecda51ef2b5dd"}, - {file = "ruff-0.0.277-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:734165ea8feb81b0d53e3bf523adc2413fdb76f1264cde99555161dd5a725522"}, - {file = "ruff-0.0.277-py3-none-win32.whl", hash = "sha256:88d0f2afb2e0c26ac1120e7061ddda2a566196ec4007bd66d558f13b374b9efc"}, - {file = "ruff-0.0.277-py3-none-win_amd64.whl", hash = "sha256:6fe81732f788894a00f6ade1fe69e996cc9e485b7c35b0f53fb00284397284b2"}, - {file = "ruff-0.0.277-py3-none-win_arm64.whl", hash = "sha256:2d4444c60f2e705c14cd802b55cd2b561d25bf4311702c463a002392d3116b22"}, - {file = "ruff-0.0.277.tar.gz", hash = "sha256:2dab13cdedbf3af6d4427c07f47143746b6b95d9e4a254ac369a0edb9280a0d2"}, + {file = "ruff-0.1.7-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:7f80496854fdc65b6659c271d2c26e90d4d401e6a4a31908e7e334fab4645aac"}, + {file = "ruff-0.1.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:1ea109bdb23c2a4413f397ebd8ac32cb498bee234d4191ae1a310af760e5d287"}, + {file = "ruff-0.1.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b0c2de9dd9daf5e07624c24add25c3a490dbf74b0e9bca4145c632457b3b42a"}, + {file = "ruff-0.1.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:69a4bed13bc1d5dabf3902522b5a2aadfebe28226c6269694283c3b0cecb45fd"}, + {file = "ruff-0.1.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:de02ca331f2143195a712983a57137c5ec0f10acc4aa81f7c1f86519e52b92a1"}, + {file = "ruff-0.1.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:45b38c3f8788a65e6a2cab02e0f7adfa88872696839d9882c13b7e2f35d64c5f"}, + {file = "ruff-0.1.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6c64cb67b2025b1ac6d58e5ffca8f7b3f7fd921f35e78198411237e4f0db8e73"}, + {file = "ruff-0.1.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9dcc6bb2f4df59cb5b4b40ff14be7d57012179d69c6565c1da0d1f013d29951b"}, + {file = "ruff-0.1.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:df2bb4bb6bbe921f6b4f5b6fdd8d8468c940731cb9406f274ae8c5ed7a78c478"}, + {file = "ruff-0.1.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:276a89bcb149b3d8c1b11d91aa81898fe698900ed553a08129b38d9d6570e717"}, + {file = "ruff-0.1.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:90c958fe950735041f1c80d21b42184f1072cc3975d05e736e8d66fc377119ea"}, + {file = "ruff-0.1.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:6b05e3b123f93bb4146a761b7a7d57af8cb7384ccb2502d29d736eaade0db519"}, + {file = "ruff-0.1.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:290ecab680dce94affebefe0bbca2322a6277e83d4f29234627e0f8f6b4fa9ce"}, + {file = "ruff-0.1.7-py3-none-win32.whl", hash = "sha256:416dfd0bd45d1a2baa3b1b07b1b9758e7d993c256d3e51dc6e03a5e7901c7d80"}, + {file = "ruff-0.1.7-py3-none-win_amd64.whl", hash = "sha256:4af95fd1d3b001fc41325064336db36e3d27d2004cdb6d21fd617d45a172dd96"}, + {file = "ruff-0.1.7-py3-none-win_arm64.whl", hash = "sha256:0683b7bfbb95e6df3c7c04fe9d78f631f8e8ba4868dfc932d43d690698057e2e"}, + {file = "ruff-0.1.7.tar.gz", hash = "sha256:dffd699d07abf54833e5f6cc50b85a6ff043715da8788c4a79bcd4ab4734d306"}, ] [[package]] @@ -3680,4 +3680,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "25211477e5ff090ff973ffb08bccd8400a813fb4bf1141756214a9e544313170" +content-hash = "de2cf9d7203422aa78a6c8a26d8b893b6bf1ac81ef0548ce0272540b7b57e67a" diff --git a/pyproject.toml b/pyproject.toml index 7ab2d74a..edc90795 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ numpy = "^1.25.2" [tool.poetry.group.dev.dependencies] pytest = "^7.4.0" black = "^23.3.0" -ruff = "^0.0.277" +ruff = "^0.1.7" taskipy = "^1.11.0" mypy = "^1.4.1" isort = "^5.12.0" From c6c371df1bb7a68ec75b4ff028443a5864958452 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 12 Dec 2023 16:01:55 -0500 Subject: [PATCH 06/11] feat: linting to pre-commit --- .pre-commit-config.yaml | 29 +++++++++++++++-------------- chasten/checks.py | 11 +++-------- chasten/configApp.py | 13 ++++--------- chasten/configuration.py | 15 +++------------ chasten/database.py | 6 +----- chasten/filesystem.py | 13 ++----------- chasten/main.py | 35 +++++++++++++++++------------------ chasten/output.py | 28 +++++++++++----------------- chasten/process.py | 9 ++------- chasten/results.py | 4 +--- chasten/server.py | 7 +++---- chasten/validate.py | 9 ++------- tests/test_checks.py | 16 ++++++++-------- tests/test_configApp.py | 7 ++----- tests/test_configuration.py | 3 +-- tests/test_constants.py | 3 +-- tests/test_createchecks.py | 3 +-- tests/test_debug.py | 3 +-- tests/test_filesystem.py | 6 ++---- tests/test_main.py | 5 +---- tests/test_util.py | 6 ++---- tests/test_validate.py | 8 ++------ 22 files changed, 85 insertions(+), 154 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b585fe04..1727ac7d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,19 @@ # configuring pre-commit hooks for chasten. # this ensures users do not commit problematic code repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: check-ast - - id: check-case-conflict - - id: check-merge-conflict - - id: forbid-submodules - - id: trailing-whitespace +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-ast + - id: check-case-conflict + - id: check-merge-conflict + - id: forbid-submodules + - id: trailing-whitespace - - repo: local - hooks: - - id: fix-imports - name: Fix Imports - entry: poetry run task fiximports - language: system +- repo: local + hooks: + - id: fix-linting + name: Fix Linting + files: python + entry: poetry run task lint --fix + language: system diff --git a/chasten/checks.py b/chasten/checks.py index c732f6c0..6e1d2b54 100644 --- a/chasten/checks.py +++ b/chasten/checks.py @@ -1,13 +1,8 @@ """Extract and analyze details about specific checks.""" -from typing import Dict -from typing import List -from typing import Tuple -from typing import Union - -from chasten import constants -from chasten import enumerations -from chasten import util +from typing import Dict, List, Tuple, Union + +from chasten import constants, enumerations, util def extract_min_max( diff --git a/chasten/configApp.py b/chasten/configApp.py index 3b8d8d24..60931957 100644 --- a/chasten/configApp.py +++ b/chasten/configApp.py @@ -1,16 +1,11 @@ # Import necessary modules and components from the Textual library, # as well as other Python modules like os and validation tools. from pathlib import Path -from typing import ClassVar -from typing import List +from typing import ClassVar, List -from textual.app import App -from textual.app import ComposeResult +from textual.app import App, ComposeResult from textual.validation import Number -from textual.widgets import Button -from textual.widgets import Input -from textual.widgets import Pretty -from textual.widgets import Static +from textual.widgets import Button, Input, Pretty, Static from chasten import constants @@ -116,7 +111,7 @@ class config_App(App): color: black; } """ - Check: ClassVar = ["", "1", False] # noqa: RUF012 + Check: ClassVar = ["", "1", False] Valid: bool = False def on_input_changed(self, event: Input.Changed) -> None: diff --git a/chasten/configuration.py b/chasten/configuration.py index d0130953..e9f9e222 100644 --- a/chasten/configuration.py +++ b/chasten/configuration.py @@ -5,25 +5,16 @@ import logging.handlers import sys from pathlib import Path -from typing import Any -from typing import Dict -from typing import List -from typing import Tuple -from typing import Union +from typing import Any, Dict, List, Tuple, Union import platformdirs import requests import yaml from rich.logging import RichHandler from rich.traceback import install -from urllib3.util import Url -from urllib3.util import parse_url +from urllib3.util import Url, parse_url -from chasten import constants -from chasten import filesystem -from chasten import output -from chasten import util -from chasten import validate +from chasten import constants, filesystem, output, util, validate def configure_tracebacks() -> None: diff --git a/chasten/database.py b/chasten/database.py index 2bab1673..fa28f7e5 100644 --- a/chasten/database.py +++ b/chasten/database.py @@ -6,11 +6,7 @@ from sqlite_utils import Database -from chasten import constants -from chasten import enumerations -from chasten import filesystem -from chasten import output -from chasten import util +from chasten import constants, enumerations, filesystem, output, util CHASTEN_SQL_SELECT_QUERY = """ SELECT diff --git a/chasten/filesystem.py b/chasten/filesystem.py index 33c2bfc5..28a3e8bb 100644 --- a/chasten/filesystem.py +++ b/chasten/filesystem.py @@ -5,21 +5,12 @@ import uuid from datetime import datetime from pathlib import Path -from typing import Any -from typing import Dict -from typing import List -from typing import NoReturn -from typing import Optional -from typing import Tuple -from typing import Union +from typing import Any, Dict, List, NoReturn, Optional, Tuple, Union import flatterer # type: ignore from rich.tree import Tree -from chasten import configuration -from chasten import constants -from chasten import database -from chasten import results +from chasten import configuration, constants, database, results CONFIGURATION_FILE_DEFAULT_CONTENTS = """ # chasten configuration diff --git a/chasten/main.py b/chasten/main.py index 346c4220..c5e38c08 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -4,29 +4,28 @@ import sys import time from pathlib import Path -from typing import Dict -from typing import List -from typing import Tuple -from typing import Union +from typing import Dict, List, Tuple, Union import pyastgrep # type: ignore import typer from pyastgrep import search as pyastgrepsearch # type: ignore -from chasten import checks -from chasten import configApp -from chasten import configuration -from chasten import constants -from chasten import createchecks -from chasten import database -from chasten import debug -from chasten import enumerations -from chasten import filesystem -from chasten import output -from chasten import process -from chasten import results -from chasten import server -from chasten import util +from chasten import ( + checks, + configApp, + configuration, + constants, + createchecks, + database, + debug, + enumerations, + filesystem, + output, + process, + results, + server, + util, +) # create a Typer object to support the command-line interface cli = typer.Typer(no_args_is_help=True) diff --git a/chasten/output.py b/chasten/output.py index c0bc78ac..f0b1e64c 100644 --- a/chasten/output.py +++ b/chasten/output.py @@ -3,20 +3,14 @@ import logging from copy import deepcopy from pathlib import Path -from typing import Any -from typing import Dict -from typing import List +from typing import Any, Dict, List from pyastgrep import search as pyastgrepsearch # type: ignore from rich.console import Console from rich.panel import Panel from rich.syntax import Syntax -from chasten import checks -from chasten import configuration -from chasten import constants -from chasten import debug -from chasten import results +from chasten import checks, configuration, constants, debug, results # declare a default logger logger: logging.Logger = logging.getLogger() @@ -45,7 +39,7 @@ def setup( def print_diagnostics(verbose: bool, **configurations: Any) -> None: """Display all variables input to the function.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 # display diagnostic information for each configuration keyword argument if verbose: console.print(":sparkles: Configured with these parameters:") @@ -59,7 +53,7 @@ def print_diagnostics(verbose: bool, **configurations: Any) -> None: def opt_print_log(verbose: bool, **contents: Any) -> None: """Produce logging information and only print when not verbose.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 # iterate through each of the configuration keyword arguments for current in contents: # print the name and the value of the keyword argument @@ -72,7 +66,7 @@ def opt_print_log(verbose: bool, **contents: Any) -> None: def print_header() -> None: """Display tool details in the header.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 console.print() console.print( constants.chasten.Emoji + constants.markers.Space + constants.chasten.Tagline @@ -82,21 +76,21 @@ def print_header() -> None: def print_server() -> None: """Display server details in the header.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 console.print(constants.output.Syslog) console.print() def print_test_start() -> None: """Display details about the test run.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 console.print(constants.output.Test_Start) console.print() def print_test_finish() -> None: """Display details about the test run.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 console.print() console.print(":sparkles: Finished running test suite for the specified program") console.print() @@ -104,7 +98,7 @@ def print_test_finish() -> None: def print_footer() -> None: """Display concluding details in the footer.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 console.print() @@ -142,7 +136,7 @@ def shorten_file_name(file_name: str, max_length: int) -> str: def print_list_contents(container: List[Path]) -> None: """Display the contents of the list in an easy-to-read fashion.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 # group all of the files by the directory that contains them; # note that this is important because the contain can contain # paths that specify files in different directories @@ -165,7 +159,7 @@ def print_list_contents(container: List[Path]) -> None: def print_analysis_details(chasten: results.Chasten, verbose: bool = False) -> None: """Print all of the verbose debugging details for the results of an analysis.""" - global console # noqa: disable=PLW0603 + global console # noqa: PLW0602 # 1) Note: see the BaseModel definitions in results.py for more details # about the objects and their relationships # 2) Note: the _match object that is inside of a Match BaseModel subclass diff --git a/chasten/process.py b/chasten/process.py index a701c059..5670b4e1 100644 --- a/chasten/process.py +++ b/chasten/process.py @@ -1,17 +1,12 @@ """Analyze the abstract syntax tree, its XML-based representation, and/or the search results.""" import json -from typing import Any -from typing import Dict -from typing import List -from typing import Tuple -from typing import Union +from typing import Any, Dict, List, Tuple, Union from pyastgrep import search as pyastgrepsearch # type: ignore from thefuzz import fuzz # type: ignore -from chasten import constants -from chasten import enumerations +from chasten import constants, enumerations def include_or_exclude_checks( diff --git a/chasten/results.py b/chasten/results.py index 7b9fd95e..d56b9101 100644 --- a/chasten/results.py +++ b/chasten/results.py @@ -3,9 +3,7 @@ import uuid from datetime import datetime from pathlib import Path -from typing import List -from typing import Optional -from typing import Union +from typing import List, Optional, Union from pyastgrep import search as pyastgrepsearch # type: ignore from pydantic import BaseModel diff --git a/chasten/server.py b/chasten/server.py index e6e813d5..af3fe246 100644 --- a/chasten/server.py +++ b/chasten/server.py @@ -4,8 +4,7 @@ import logging.handlers import socketserver -from chasten import constants -from chasten import output +from chasten import constants, output LOG_FILE = constants.server.Log_File HOST = constants.server.Localhost @@ -19,7 +18,7 @@ class SyslogUDPHandler(socketserver.BaseRequestHandler): def handle(self): """Receive a message and then display it in output and log it to a file.""" - global logger # noqa: disable=PLW0603 + global logger # noqa: PLW0602 # receive the message from the syslog logging client message = bytes.decode( self.request[0].strip(), encoding=constants.server.Utf8_Encoding @@ -39,7 +38,7 @@ def handle(self): def start_syslog_server(): """Start a syslog server.""" - global logger # noqa: disable=PLW0603 + global logger # noqa: PLW0602 # always log all of the messages to a file logger.setLevel(logging.DEBUG) # create a RotatingFileHandler such that: diff --git a/chasten/validate.py b/chasten/validate.py index bca221c8..1b25e0a9 100644 --- a/chasten/validate.py +++ b/chasten/validate.py @@ -1,16 +1,11 @@ """Validate various aspects of configurations and command-line arguments.""" -from typing import Any -from typing import Dict -from typing import List -from typing import Tuple +from typing import Any, Dict, List, Tuple import jsonschema from jsonschema.exceptions import ValidationError -from chasten import constants -from chasten import output -from chasten import util +from chasten import constants, output, util # intuitive description: # a configuration file links to one or more checks files diff --git a/tests/test_checks.py b/tests/test_checks.py index 96bfa0e1..0e2ec8a9 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -2,16 +2,16 @@ import hypothesis.strategies as st import pytest -from hypothesis import HealthCheck -from hypothesis import given -from hypothesis import settings +from hypothesis import HealthCheck, given, settings from hypothesis_jsonschema import from_schema -from chasten.checks import check_match_count -from chasten.checks import extract_description -from chasten.checks import extract_min_max -from chasten.checks import is_in_closed_interval -from chasten.checks import make_checks_status_message +from chasten.checks import ( + check_match_count, + extract_description, + extract_min_max, + is_in_closed_interval, + make_checks_status_message, +) from chasten.validate import JSON_SCHEMA_CHECKS JSON_SCHEMA_COUNT = { diff --git a/tests/test_configApp.py b/tests/test_configApp.py index 854219b9..9850774f 100644 --- a/tests/test_configApp.py +++ b/tests/test_configApp.py @@ -1,13 +1,10 @@ import pathlib import pytest -from hypothesis import HealthCheck -from hypothesis import given -from hypothesis import settings +from hypothesis import HealthCheck, given, settings from hypothesis import strategies as st -from chasten import configApp -from chasten import constants +from chasten import configApp, constants # Define an alphabet of characters for generating random test data ALPHABET = "0123456789!@#$%^&*()_+-=[]|:;'<>.?/~`AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz" diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 184dd0fe..739572a4 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -3,8 +3,7 @@ import logging import pytest -from hypothesis import given -from hypothesis import strategies +from hypothesis import given, strategies from chasten import configuration diff --git a/tests/test_constants.py b/tests/test_constants.py index 5c119dd7..b914e588 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -4,8 +4,7 @@ from pathlib import Path import pytest -from hypothesis import given -from hypothesis import strategies +from hypothesis import given, strategies from chasten import constants diff --git a/tests/test_createchecks.py b/tests/test_createchecks.py index 27219405..9a924fca 100644 --- a/tests/test_createchecks.py +++ b/tests/test_createchecks.py @@ -3,8 +3,7 @@ import pytest -from chasten.createchecks import generate_yaml_config -from chasten.createchecks import is_valid_api_key +from chasten.createchecks import generate_yaml_config, is_valid_api_key def get_valid_api_key(): diff --git a/tests/test_debug.py b/tests/test_debug.py index e486f86d..0303ea8d 100644 --- a/tests/test_debug.py +++ b/tests/test_debug.py @@ -2,8 +2,7 @@ import pytest -from chasten.debug import DebugDestination -from chasten.debug import DebugLevel +from chasten.debug import DebugDestination, DebugLevel def test_debug_level_values(): diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py index 85122597..5cd032f2 100644 --- a/tests/test_filesystem.py +++ b/tests/test_filesystem.py @@ -5,12 +5,10 @@ from unittest.mock import patch import pytest -from hypothesis import given -from hypothesis import strategies +from hypothesis import given, strategies from rich.tree import Tree -from chasten import constants -from chasten import filesystem +from chasten import constants, filesystem def test_valid_directory() -> None: diff --git a/tests/test_main.py b/tests/test_main.py index 8f43a1d0..65369ed5 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -5,10 +5,7 @@ from unittest.mock import patch import pytest -from hypothesis import HealthCheck -from hypothesis import given -from hypothesis import settings -from hypothesis import strategies +from hypothesis import HealthCheck, given, settings, strategies from typer.testing import CliRunner from chasten import main diff --git a/tests/test_util.py b/tests/test_util.py index c411d38d..7ed69a7c 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -3,12 +3,10 @@ import shutil import pytest -from hypothesis import given -from hypothesis import provisional +from hypothesis import given, provisional from hypothesis import strategies as st -from chasten import constants -from chasten import util +from chasten import constants, util def test_human_readable_boolean() -> None: diff --git a/tests/test_validate.py b/tests/test_validate.py index 6625a401..87845f23 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -1,14 +1,10 @@ """Pytest test suite for the validate module.""" import pytest -from hypothesis import HealthCheck -from hypothesis import given -from hypothesis import settings -from hypothesis import strategies +from hypothesis import HealthCheck, given, settings, strategies from hypothesis_jsonschema import from_schema -from chasten.validate import JSON_SCHEMA_CONFIG -from chasten.validate import validate_configuration +from chasten.validate import JSON_SCHEMA_CONFIG, validate_configuration def test_validate_config_valid_realistic(): From ac5f7986a5ce63cb73c496e3b5579f1a0b152446 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 12 Dec 2023 16:04:07 -0500 Subject: [PATCH 07/11] feat: pre-commit linting on python files --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1727ac7d..44c2d66d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,6 +14,6 @@ repos: hooks: - id: fix-linting name: Fix Linting - files: python + types: [python] entry: poetry run task lint --fix language: system From 1c5a53163654a679ccc540a645dc1162b0fc4c71 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 12 Dec 2023 16:06:46 -0500 Subject: [PATCH 08/11] feat: pre-commit linting on python files --- .pre-commit-config.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 44c2d66d..e2dd3991 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,7 @@ repos: rev: v4.5.0 hooks: - id: check-ast + files: '\.py$' - id: check-case-conflict - id: check-merge-conflict - id: forbid-submodules @@ -13,7 +14,7 @@ repos: - repo: local hooks: - id: fix-linting - name: Fix Linting - types: [python] entry: poetry run task lint --fix + files: '\.py$' language: system + name: Fix Linting From c2a59a3a34c6b7f80c0ffe9c60e1186fb844c2d5 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 12 Dec 2023 16:07:58 -0500 Subject: [PATCH 09/11] feat: pre-commit linting on python files --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e2dd3991..9a546659 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: rev: v4.5.0 hooks: - id: check-ast - files: '\.py$' + files: '.*\.py$' - id: check-case-conflict - id: check-merge-conflict - id: forbid-submodules @@ -15,6 +15,6 @@ repos: hooks: - id: fix-linting entry: poetry run task lint --fix - files: '\.py$' + files: '.*\.py$' language: system name: Fix Linting From bb36cac5da6202e4ff267a091babdd77d6d5a708 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 12 Dec 2023 16:09:49 -0500 Subject: [PATCH 10/11] feat: pre-commit linting on python files --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a546659..fd5c7bfb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: rev: v4.5.0 hooks: - id: check-ast - files: '.*\.py$' + files: \.py$ - id: check-case-conflict - id: check-merge-conflict - id: forbid-submodules @@ -15,6 +15,6 @@ repos: hooks: - id: fix-linting entry: poetry run task lint --fix - files: '.*\.py$' + files: \.py$ language: system name: Fix Linting From c71957cbdd154e8a94e2773aca73d884cad12234 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 12 Dec 2023 16:14:26 -0500 Subject: [PATCH 11/11] feat: pre-commit linting on python files --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fd5c7bfb..50a37d9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: rev: v4.5.0 hooks: - id: check-ast - files: \.py$ + files: '\.py$' - id: check-case-conflict - id: check-merge-conflict - id: forbid-submodules @@ -14,7 +14,7 @@ repos: - repo: local hooks: - id: fix-linting + files: '\.py$' entry: poetry run task lint --fix - files: \.py$ language: system name: Fix Linting