Skip to content

Commit

Permalink
feat: init pre-commit settings via poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
simojo committed Dec 1, 2023
1 parent d33c0e4 commit 5645e82
Show file tree
Hide file tree
Showing 24 changed files with 253 additions and 64 deletions.
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 8 additions & 3 deletions chasten/checks.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
11 changes: 8 additions & 3 deletions chasten/configApp.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 12 additions & 9 deletions chasten/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion chasten/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions chasten/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 18 additions & 17 deletions chasten/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions chasten/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions chasten/process.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
4 changes: 3 additions & 1 deletion chasten/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion chasten/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions chasten/validate.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit 5645e82

Please sign in to comment.