Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@
#
repos:
# Autoformat: Python code
- repo: https://github.com/ambv/black
rev: 23.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: f0fe93c067104b76ffb58852abe79673a8429bd1 # frozen: v0.11.8
hooks:
- id: black
- id: ruff
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
- id: ruff-format

# Autoformat: markdown, yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
rev: 787fb9f542b140ba0b2aced38e6a3e68021647a3 # frozen: v3.5.3
hooks:
- id: prettier
exclude: tests/.*

# Autoformat: https://github.com/asottile/reorder_python_imports
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: reorder-python-imports

# Misc...
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0
# ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available
hooks:
# Autoformat: Makes sure files end in a newline and only a newline.
- id: end-of-file-fixer
exclude: tests/.*

# Autoformat: Sorts entries in requirements.txt.
- id: requirements-txt-fixer

# Lint: Check for files with names that would conflict on a
# case-insensitive filesystem like MacOS HFS+ or Windows FAT.
# Sanity checks
- id: check-added-large-files
- id: check-case-conflict

# Lint: Checks that non-binary executables have a proper shebang.
- id: check-executables-have-shebangs
- id: check-illegal-windows-names
- id: check-merge-conflict

# Lint: Python code
- repo: https://github.com/pycqa/flake8
rev: "6.0.0"
hooks:
- id: flake8
# Checks based on file type
- id: check-toml
- id: check-yaml

# Detect mistakes
- id: debug-statements
- id: detect-private-key
- id: forbid-submodules

# Automatic fixes
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
- id: requirements-txt-fixer
- id: end-of-file-fixer
exclude: tests/.*
1 change: 1 addition & 0 deletions github_activity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__version__ = "1.0.3"
__all__ = ["get_activity", "generate_activity_md"]

from .github_activity import get_activity, generate_activity_md
11 changes: 4 additions & 7 deletions github_activity/github_activity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Use the GraphQL api to grab issues/PRs that match a query."""

import dataclasses
import datetime
import fnmatch
Expand All @@ -7,10 +8,8 @@
import shlex
import subprocess
import sys
import urllib
from collections import OrderedDict
from json import loads
from pathlib import Path
from subprocess import CalledProcessError
from subprocess import PIPE
from subprocess import run
Expand Down Expand Up @@ -567,8 +566,6 @@ def filter_ignored(userlist):
return

# Separate into closed and opened
until_dt_str = data.until_dt_str
since_dt_str = data.since_dt_str
closed = data.query("closedAt >= @since_dt_str and closedAt <= @until_dt_str")
opened = data.query("createdAt >= @since_dt_str and createdAt <= @until_dt_str")

Expand Down Expand Up @@ -691,7 +688,7 @@ def filter_ignored(userlist):
items["md"].append("")

for irow, irowdata in items["data"].iterrows():
author = irowdata["author"]
# author = irowdata["author"]
ititle = irowdata["title"]
if strip_brackets and ititle.strip().startswith("[") and "]" in ititle:
ititle = ititle.split("]", 1)[-1].strip()
Expand Down Expand Up @@ -855,11 +852,11 @@ def _get_datetime_and_type(org, repo, datetime_or_git_ref, auth):
try:
dt = _get_datetime_from_git_ref(org, repo, datetime_or_git_ref, auth)
return (dt, True)
except Exception as ref_error:
except Exception:
try:
dt = dateutil.parser.parse(datetime_or_git_ref)
return (dt, False)
except Exception as datetime_error:
except Exception:
raise ValueError(
"{0} not found as a ref or valid date format".format(
datetime_or_git_ref
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ search = 'version = "{current_version}"'
[[tool.tbump.file]]
src = "github_activity/__init__.py"
search = '__version__ = "{current_version}"'

[tool.ruff.lint.per-file-ignores]
"docs/conf.py" = ["E402"]
3 changes: 1 addition & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import shutil
from pathlib import Path
from subprocess import run
Expand Down Expand Up @@ -126,7 +125,7 @@ def test_cli_ignore_user(tmpdir):
cmd = f"github-activity executablebooks/github-activity --ignore-contributor choldgraf -s v1.0.2 -o {path_output}"
run(cmd.split(), check=True)
md = path_output.read_text()
assert not "@choldgraf" in md
assert "@choldgraf" not in md


def test_contributor_sorting(tmpdir, file_regression):
Expand Down
Loading