Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Burocrata to check and add license notices #469

Merged
merged 2 commits into from
Mar 8, 2024
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
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exclude =
.git,
__pycache__,
.ipynb_checkpoints,
doc/_build,
per-file-ignores =
# disable unused-imports errors on __init__.py
__init__.py: F401
Expand Down
58 changes: 5 additions & 53 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ on:

###############################################################################
jobs:
black:
name: black [format]
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -37,10 +36,9 @@ jobs:
run: pip freeze

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

isort:
name: isort [format]
style:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -51,53 +49,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install requirements
run: pip install -r env/requirements-style.txt

- name: List installed packages
run: pip freeze

- name: Check code format
run: make isort-check

flake8:
name: flake8 [style]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install requirements
run: pip install -r env/requirements-style.txt

- name: List installed packages
run: pip freeze

- name: Check code style
run: make flake8

license:
name: license notice [style]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"

- name: Install requirements
run: pip install -r env/requirements-style.txt
Expand All @@ -106,4 +58,4 @@ jobs:
run: pip freeze

- name: Check code style
run: make license-check
run: make check-style
28 changes: 9 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PROJECT=harmonica
TESTDIR=tmp-test-dir-with-unique-name
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules --doctest-continue-on-failure -v --pyargs
NUMBATEST_ARGS=--doctest-modules -v --pyargs -m use_numba
STYLE_CHECK_FILES=$(PROJECT) examples doc/conf.py tools
STYLE_CHECK_FILES=$(PROJECT) examples doc

help:
@echo "Commands:"
Expand Down Expand Up @@ -39,29 +39,19 @@ test_numba:
cd $(TESTDIR); NUMBA_DISABLE_JIT=0 MPLBACKEND='agg' pytest $(NUMBATEST_ARGS) $(PROJECT)
rm -rvf $(TESTDIR)

format: license isort black

check: isort-check black-check license-check flake8

black:
format:
isort $(STYLE_CHECK_FILES)
black $(STYLE_CHECK_FILES)
burocrata --extension=py $(STYLE_CHECK_FILES)

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

isort:
isort $(STYLE_CHECK_FILES)

isort-check:
check-format:
isort --check $(STYLE_CHECK_FILES)
black --check $(STYLE_CHECK_FILES)
burocrata --check --extension=py $(STYLE_CHECK_FILES)

license:
python tools/license_notice.py

license-check:
python tools/license_notice.py --check

flake8:
check-style:
flake8 $(STYLE_CHECK_FILES)

clean:
Expand Down
1 change: 1 addition & 0 deletions env/requirements-style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ flake8-rst-docstrings==0.3.*
flake8-simplify==0.19.*
flake8-unused-arguments==0.0.12
pep8-naming==0.13.*
burocrata==0.2.*
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ dependencies:
- flake8-simplify==0.19.*
- flake8-unused-arguments==0.0.12
- pep8-naming==0.13.*
- pip:
- burocrata==0.2.*
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ markers = [
[tool.isort]
profile = "black"
multi_line_output = 3

[tool.burocrata]
notice = '''
# Copyright (c) 2018 The Harmonica 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)
#'''
94 changes: 0 additions & 94 deletions tools/license_notice.py

This file was deleted.