Commit 22c1dffc authored by nimrod's avatar nimrod
Browse files

pre-commit stuff.

- Replace prospector with Pylint and Bandit. Those are the only tools
  not already configured in pre-commit. This way provides better
  control, better outputs and seems more reliable.
- Remove the GitLab CI linter, doesn't work.
- Address a bunch of pre-commit issues.
parent e785236c
Loading
Loading
Loading
Loading
+18 −35
Original line number Diff line number Diff line
@@ -46,33 +46,24 @@ repos:
          - |
            --line-length=79

  - repo: https://github.com/PyCQA/prospector
    rev: v1.12.1
  - repo: https://github.com/pylint-dev/pylint.git
    rev: v3.3.3
    hooks:
      - id: prospector
      - id: pylint
        exclude: *excluded_pythonscripts
        args: ["--disable", "line-too-long,broad-exception-raised"]

  - repo: https://github.com/DanielNoord/pydocstringformatter.git
    rev: v0.7.3
    hooks:
      - id: pydocstringformatter
        exclude: *excluded_pythonscripts

  - repo: https://github.com/PyCQA/bandit.git
    rev: "1.8.0"
    hooks:
      - id: bandit
        exclude: *excluded_pythonscripts
        args:
          - |-
            --max-line-length=79
          - |-
            --with-tool=pyroma
          - |-
            --with-tool=bandit
          - |-
            --without-tool=pep257
          - |-
            --doc-warnings
          - |-
            --test-warnings
          - |-
            --full-pep8
          - |-
            --strictness=high
          - |-
            --no-autodetect
        additional_dependencies:
          - bandit
          - pyroma

  - repo: https://github.com/pycqa/flake8.git
    rev: 7.1.1
@@ -92,7 +83,7 @@ repos:
        exclude: rabbitmqadmin|\.config/git/config|Pipfile\.lock|npmrc

  - repo: https://git.shore.co.il/nimrod/pre-commit-hooks.git
    rev: v0.5.1
    rev: v0.5.2
    hooks:
      - id: shell-validate
        exclude: &excluded_shellscripts |-
@@ -111,18 +102,10 @@ repos:
        types: [text]

  - repo: https://github.com/executablebooks/mdformat.git
    rev: 0.7.17
    rev: 0.7.21
    hooks:
      - id: mdformat

  - repo: https://gitlab.com/devopshq/gitlab-ci-linter
    rev: v1.0.6
    hooks:
      - id: gitlab-ci-linter
        args:
          - "--server"
          - https://git.shore.co.il

  - repo: https://github.com/codespell-project/codespell.git
    rev: v2.3.0
    hooks:
+1 −1
Original line number Diff line number Diff line
last_month != date +%Y-%m --date 'last month'
last_zip != find -maxdepth 1 -name '*.zip' \! -name '${last_month}.zip' -printf '%f\n' | sort -r | head -1
new_files != find reciepts/ -type f -newer ${last_zip}
new_files != find receipts/ -type f -newer ${last_zip}

.PHONY: send
send: ${last_month}.zip
+9 −10
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ GH_MIRROR_PREFIX = "https://*****@github.com/"

def error(message):
    """Print an error message with the current subparser's usage and exit."""
    # pylint: disable=protected-access
    # pylint: disable=protected-access,possibly-used-before-assignment
    sub_parser = arg_parser._subparsers._actions[1].choices[_args.command]
    sub_parser.error(message)

@@ -62,7 +62,7 @@ def mirror_project(project, gh_conn, token):
    except github3.exceptions.NotFoundError:
        gh_repo = gh_conn.create_repository(project.name)
        print(
            f"Created a new GitHub reposiroty {gh_repo.html_url}.",
            f"Created a new GitHub repository {gh_repo.html_url}.",
            file=sys.stderr,
        )

@@ -96,7 +96,7 @@ def get_mirror_token():
    Reads it from a Keepass password database using Passhole.
    """
    ENTRY_PATH = "Web Sites/GitHub".split("/")  # noqa
    TOKEN_FIELD = "GitLab mirroring token"  # noqa nosec
    TOKEN_FIELD = "GitLab mirroring token"  # nosec # noqa

    # The following line requires an interactive session for getting the
    # password.
@@ -152,9 +152,9 @@ def guess_name(args, gh_conn=None, gl_conn=None):
            error("Name not provided and not in a Git repo.")

        remote = guess_remote(
            remote_type="github"
            if "github" in args and args.github
            else "gitlab",
            remote_type=(
                "github" if "github" in args and args.github else "gitlab"
            ),
            gl_conn=gl_conn,
        )
        if remote is None:
@@ -162,7 +162,6 @@ def guess_name(args, gh_conn=None, gl_conn=None):
                error("Name not provided and could not find a GitHub remote.")
            else:
                error("Name not provided and could not find a GitLab remote.")
        else:
        if "github" in args and args.github:
            name = rcfiles.github.url_to_name(remote["url"])
        else:
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ else
    notify='notify'
fi

eval "$@" || code="$?"
eval "$*" || code="$?"
code="${code:-0}"

if [ "$code" -eq 0 ]
+2 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ import sys
import webbrowser

import xdg.BaseDirectory  # pylint: disable=import-error
import yaml
import yaml  # pylint: disable=import-error

EXAMPLE_CONFIG = """---
general:
@@ -46,6 +46,7 @@ def get_config(path=None):
    if path:
        path = path.expanduser()
        if not path.exists() and not path.is_file():
            # pylint: disable=possibly-used-before-assignment
            arg_parser.error("Configuration file does not exist.")

    else:
+1 −1

File changed.

Contains only whitespace changes.

Loading