Run black locally with nox (#776)
* Run black locally with nox * Update contributor instructions * Fix workflowpull/787/head
parent
4733eb333a
commit
8f52578e85
|
@ -1,25 +1,15 @@
|
||||||
**Pull request**
|
**Pull request**
|
||||||
|
|
||||||
Please remove this paragraph and replace it with a description of your PR.
|
Please *remove* this paragraph and replace it with a description of your PR. Also include the issue that it fixes.
|
||||||
Also include links to the issues that it fixes.
|
|
||||||
|
|
||||||
**How Has This Been Tested?**
|
**How Has This Been Tested?**
|
||||||
|
|
||||||
Please repalce this paragraph with a description of how this PR has been
|
Please *remove* this paragraph with a description of how this PR has been tested.
|
||||||
tested. Include the necessary instructions and files such that other can
|
|
||||||
reproduce it.
|
|
||||||
|
|
||||||
**Checklist**
|
**Checklist**
|
||||||
|
|
||||||
- [ ] I have formatted my code with [black](https://github.com/psf/black).
|
- [ ] I have read [CONTRIBUTING.md](../CONTRIBUTING.md).
|
||||||
- [ ] I have added tests that prove my fix is effective or that my feature
|
- [ ] I have added a concise human-readable description of the change to [CHANGELOG.md](../CHANGELOG.md).
|
||||||
works
|
- [ ] I have tested that this fix is effective or that this feature works.
|
||||||
- [ ] I have added docstrings to newly created methods and classes
|
- [ ] I have added docstrings to newly created methods and classes.
|
||||||
- [ ] I have optimized the code at least one time after creating the initial
|
- [ ] I have updated the [README.md](../README.md) and the [readthedocs](../docs/source) documentation. Or verified that this is not necessary.
|
||||||
version
|
|
||||||
- [ ] I have updated the [README.md](../README.md) or verified that this
|
|
||||||
is not necessary
|
|
||||||
- [ ] I have updated the [readthedocs](../docs/source) documentation or
|
|
||||||
verified that this is not necessary
|
|
||||||
- [ ] I have added a concise human-readable description of the change to
|
|
||||||
[CHANGELOG.md](../CHANGELOG.md)
|
|
||||||
|
|
|
@ -16,13 +16,22 @@ env:
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
check-code-formatting:
|
check-code-formatting:
|
||||||
name: Check code formatting
|
name: Check coding style
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Check code formatting
|
- name: Set up Python ${{ env.default-python }}
|
||||||
uses: psf/black@stable
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.default-python }}
|
||||||
|
- name: Upgrade pip, Install nox
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install nox
|
||||||
|
- name: Check coding style
|
||||||
|
run: |
|
||||||
|
nox --error-on-missing-interpreters --non-interactive --session format
|
||||||
|
|
||||||
check-coding-style:
|
check-coding-style:
|
||||||
name: Check coding style
|
name: Check coding style
|
||||||
|
|
|
@ -26,20 +26,25 @@ Any contribution is appreciated! You might want to:
|
||||||
|
|
||||||
## Guideline for creating pull request
|
## Guideline for creating pull request
|
||||||
|
|
||||||
* A pull request should close an existing issue.
|
* A pull request should close an existing issue. For example, use "Fix #123" to indicate that your PR fixes issue 123.
|
||||||
* Pull requests should be merged to master. Version tags are used indicate the releases.
|
* Pull requests should be merged to master.
|
||||||
* Include unit tests when possible. In case of bugs, this will help to prevent the same mistake in the future. In case
|
* Include unit tests when possible. In case of bugs, this will help to prevent the same mistake in the future. In case
|
||||||
of features, this will show that your code works correctly.
|
of features, this will show that your code works correctly.
|
||||||
* Code should work for Python 3.6+.
|
* Code should work for Python 3.6+.
|
||||||
* Code should be formatted with [black](https://github.com/psf/black).
|
* Test your code by using nox (see below).
|
||||||
* New features should be well documented using docstrings.
|
* New features should be well documented using docstrings.
|
||||||
|
* Check if the [README.md](../README.md) or [readthedocs](../docs/source) documentation needs to be updated.
|
||||||
* Check spelling and grammar.
|
* Check spelling and grammar.
|
||||||
* Don't forget to update the [CHANGELOG.md](CHANGELOG.md#[Unreleased])
|
* Don't forget to update the [CHANGELOG.md](CHANGELOG.md#[Unreleased]).
|
||||||
|
|
||||||
## Guidelines for posting comments
|
## Guidelines for posting comments
|
||||||
|
|
||||||
* [Be cordial and positive](https://www.kennethreitz.org/essays/be-cordial-or-be-on-your-way)
|
* [Be cordial and positive](https://www.kennethreitz.org/essays/be-cordial-or-be-on-your-way)
|
||||||
|
|
||||||
|
## Guidelines for publishing
|
||||||
|
|
||||||
|
* Publishing is automated. Add a YYYYMMDD version tag and GitHub workflows will do the rest.
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
1. Clone the repository
|
1. Clone the repository
|
||||||
|
@ -68,9 +73,3 @@ Any contribution is appreciated! You might want to:
|
||||||
```sh
|
```sh
|
||||||
nox -e py36
|
nox -e py36
|
||||||
```
|
```
|
||||||
|
|
||||||
4. After changing the code, run the black formatter.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
black .
|
|
||||||
```
|
|
||||||
|
|
21
noxfile.py
21
noxfile.py
|
@ -1,20 +1,37 @@
|
||||||
|
import os
|
||||||
|
|
||||||
import nox
|
import nox
|
||||||
|
|
||||||
|
|
||||||
PYTHON_ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]
|
PYTHON_ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]
|
||||||
|
PYTHON_MODULES = ["pdfminer", "tools", "tests", "noxfile.py", "setup.py"]
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session
|
||||||
|
def format(session):
|
||||||
|
session.install("black")
|
||||||
|
# Format files locally with black, but only check in cicd
|
||||||
|
if "CI" in os.environ:
|
||||||
|
session.run("black", "--check", *PYTHON_MODULES)
|
||||||
|
else:
|
||||||
|
session.run("black", *PYTHON_MODULES)
|
||||||
|
|
||||||
|
|
||||||
@nox.session
|
@nox.session
|
||||||
def lint(session):
|
def lint(session):
|
||||||
session.install("flake8")
|
session.install("flake8")
|
||||||
session.run("flake8", "pdfminer/", "tools/", "tests/", "--count", "--statistics")
|
session.run("flake8", *PYTHON_MODULES, "--count", "--statistics")
|
||||||
|
|
||||||
|
|
||||||
@nox.session
|
@nox.session
|
||||||
def types(session):
|
def types(session):
|
||||||
session.install("mypy")
|
session.install("mypy")
|
||||||
session.run(
|
session.run(
|
||||||
"mypy", "--install-types", "--non-interactive", "--show-error-codes", "."
|
"mypy",
|
||||||
|
"--install-types",
|
||||||
|
"--non-interactive",
|
||||||
|
"--show-error-codes",
|
||||||
|
*PYTHON_MODULES,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -5,8 +5,7 @@ from setuptools import setup
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
sys.path.append(str(Path(__file__).parent))
|
sys.path.append(str(Path(__file__).parent))
|
||||||
import pdfminer as package
|
import pdfminer as package # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
with open(path.join(path.abspath(path.dirname(__file__)), "README.md")) as f:
|
with open(path.join(path.abspath(path.dirname(__file__)), "README.md")) as f:
|
||||||
readme = f.read()
|
readme = f.read()
|
||||||
|
|
Loading…
Reference in New Issue