Skip to content

Commit

Permalink
Use Burocrata to check and add license notices (#402)
Browse files Browse the repository at this point in the history
Replaces our custom script in `tools`. Checks that all files have a
license notice and adds it if they are missing one. Simplify the
`Makefile` to distinguish only between checking style and format instead
of each individual tool.
  • Loading branch information
leouieda authored Mar 8, 2024
1 parent 7a1e242 commit b32d389
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 109 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: python -m pip freeze

- name: Check code format
run: make black-check license-check
run: make check-format

style:
runs-on: ubuntu-latest
Expand All @@ -58,4 +58,4 @@ jobs:
run: python -m pip freeze

- name: Check code style
run: make flake8 lint
run: make check-style lint
22 changes: 8 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PROJECT=pooch
TESTDIR=tmp-test-dir-with-unique-name
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --pyargs
LINT_FILES=$(PROJECT)
CHECK_STYLE=doc/conf.py $(PROJECT) tools
CHECK_STYLE=$(PROJECT) doc

help:
@echo "Commands:"
Expand All @@ -30,23 +30,17 @@ test:
cp $(TESTDIR)/.coverage* .
rm -r $(TESTDIR)

format: license black

check: black-check license-check flake8

black:
format:
black $(CHECK_STYLE)
burocrata --extension=py $(CHECK_STYLE)

black-check:
black --check $(CHECK_STYLE)
check: check-format check-style

license:
python tools/license_notice.py

license-check:
python tools/license_notice.py --check
check-format:
black --check $(CHECK_STYLE)
burocrata --check --extension=py $(CHECK_STYLE)

flake8:
check-style:
flake8 $(CHECK_STYLE)

lint:
Expand Down
1 change: 1 addition & 0 deletions env/requirements-style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ black
flake8
pylint>=2.4
pathspec
burocrata
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ dependencies:
- black>=20.8b1
- flake8
- pylint>=2.4
- pip:
- burocrata
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ write_to = "pooch/_version.py"
markers = [
"network: test requires network access",
]

[tool.burocrata]
notice = '''
# Copyright (c) 2018 The Pooch Developers.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
#
# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
#'''
93 changes: 0 additions & 93 deletions tools/license_notice.py

This file was deleted.

0 comments on commit b32d389

Please sign in to comment.