Skip to content

Commit e003c24

Browse files
committed
Switch back to .githubactivity.json
This project is written in Python, but it can be used with any GitHub repo, so shouldn't rely on pyproject.toml
1 parent 4882440 commit e003c24

File tree

5 files changed

+11
-26
lines changed

5 files changed

+11
-26
lines changed

github_activity/cli.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import argparse
2+
import json
23
import os
34
import sys
45
from subprocess import PIPE
56
from subprocess import run
67

7-
if sys.version_info >= (3, 11):
8-
import tomllib
9-
else:
10-
import tomli as tomllib
11-
12-
138
from .git import _git_installed_check
149
from .github_activity import _parse_target
1510
from .github_activity import generate_activity_md
@@ -146,19 +141,13 @@
146141

147142
def load_config_and_defaults(args):
148143
"""
149-
Load github-activity config from pyproject.toml if it exists,
150-
override unset args with values from pyproject.toml,
144+
Load .githubactivity.json from the current directory,
145+
override unset args with values from .githubactivity.json,
151146
and set defaults for remaining args.
152-
153-
args: An argparse namespace object containing the parsed arguments.
154-
Fields which are None will be replaced with the configuration from
155-
pyproject.toml, or a default if not set.
156-
The args object is modified in place.
157147
"""
158148
try:
159-
with open("pyproject.toml", "rb") as f:
160-
pyproject = tomllib.load(f)
161-
config = pyproject.get("tool", {}).get("github-activity", {})
149+
with open(".githubactivity.json") as f:
150+
config = json.load(f)
162151
except FileNotFoundError:
163152
config = {}
164153

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ numpy
33
pandas
44
python-dateutil
55
requests
6-
tomli >= 1.1.0 ; python_version < "3.11"
76
tqdm

tests/resources/cli_no_target-pyproject.toml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"heading-level": 5
3+
}

tests/test_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_cli(tmpdir, file_regression, cmd, basename):
4545
file_regression.check(md, basename=basename, extension=".md")
4646

4747

48-
def test_cli_pyproject_config(tmp_path, monkeypatch, file_regression):
48+
def test_cli_dot_config(tmp_path, monkeypatch, file_regression):
4949
"""Test that pyproject.toml config is loaded"""
5050
cmd = "github-activity -s 2019-09-01 -u 2019-11-01 -o {path_output}"
5151
basename = "cli_no_target_pyproject"
@@ -56,8 +56,8 @@ def test_cli_pyproject_config(tmp_path, monkeypatch, file_regression):
5656
shutil.copytree(str(repo_dir), str(tmp_path), dirs_exist_ok=True)
5757
monkeypatch.chdir(tmp_path)
5858
shutil.copyfile(
59-
repo_dir / "tests" / "resources" / "cli_no_target-pyproject.toml",
60-
"pyproject.toml",
59+
repo_dir / "tests" / "resources" / "cli_no_target.githubactivity.json",
60+
".githubactivity.json",
6161
)
6262

6363
command = cmd.format(path_output=path_output)

0 commit comments

Comments
 (0)