Skip to content

Commit

Permalink
Merge pull request #212 from lpsinger/pre-commit
Browse files Browse the repository at this point in the history
Add pre-commit hooks
  • Loading branch information
dakota002 authored Aug 5, 2024
2 parents 6f39d38 + 509a01f commit ddef581
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 188 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

18 changes: 8 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,21 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- uses: psf/black@stable

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: pip install pre-commit poetry

- name: Install package
run: poetry install
- name: Run pre-commit checks
run: pre-commit run --all-files

- name: Run flake8 linter
run: poetry run flake8
- name: Install package
run: poetry install --all-extras

# - name: Run unit tests
# - name: Run unit tests
# run: poetry run pytest . --cov --cov-report=xml

# - name: Upload coverage to codecov
Expand Down
45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
# Prevent giant files from being committed.
- id: check-case-conflict
# Check for files with names that would conflict on a case-insensitive
# filesystem like MacOS HFS+ or Windows FAT.
- id: check-json
# Attempts to load all json files to verify syntax.
- id: check-merge-conflict
# Check for files that contain merge conflict strings.
- id: check-symlinks
# Checks for symlinks which do not point to anything.
- id: check-toml
# Attempts to load all TOML files to verify syntax.
- id: check-xml
# Attempts to load all xml files to verify syntax.
- id: check-yaml
# Attempts to load all yaml files to verify syntax.
- id: detect-private-key
# Checks for the existence of private keys.
- id: end-of-file-fixer
# Makes sure files end in a newline and only a newline.
- id: trailing-whitespace
# Trims trailing whitespace.
exclude_types: [python] # Covered by Ruff W291.
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.5
hooks:
# Run the linter.
- id: ruff
args: ["--extend-select", "I", "--fix"]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/python-poetry/poetry
rev: "1.8.3"
hooks:
- id: poetry-check
- id: poetry-lock
args: ["--no-update"]
2 changes: 1 addition & 1 deletion gcn_email/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import click
import prometheus_client

from .core import connect_as_consumer, subscribe_to_topics, recieve_alerts
from .core import connect_as_consumer, recieve_alerts, subscribe_to_topics

log = logging.getLogger(__name__)

Expand Down
10 changes: 5 additions & 5 deletions gcn_email/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
#
# SPDX-License-Identifier: Apache-2.0
#
from email.message import EmailMessage
import json
import logging
import os
import json
from email.message import EmailMessage

import backoff
import boto3
from boto3.dynamodb.conditions import Key
from gcn_kafka import Consumer, config_from_env
from ratelimit import limits, RateLimitException
import backoff
from ratelimit import RateLimitException, limits

from .helpers import periodic_task
from . import metrics
from .helpers import periodic_task

SESV2 = boto3.client("sesv2")
SENDER = f'GCN Notices <{os.environ["EMAIL_SENDER"]}>'
Expand Down
1 change: 1 addition & 0 deletions gcn_email/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# SPDX-License-Identifier: Apache-2.0
#
"""Prometheus metrics."""

import prometheus_client

received = prometheus_client.Counter(
Expand Down
167 changes: 1 addition & 166 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ ratelimit = "*"
click = "^8.1.3"
prometheus-client = "^0.17.0"

[tool.poetry.group.dev.dependencies]
black = "*"
flake8 = "*"

[tool.poetry.scripts]
gcn-email = "gcn_email.cli:main"

Expand Down

0 comments on commit ddef581

Please sign in to comment.