Skip to content

Commit 3d058cf

Browse files
Merge pull request #18 from developmentseed/updateCiAndPre-Commit
update CI and pre-commit, add setup.cfg for lint configs
2 parents 9e7e91a + c5d2433 commit 3d058cf

17 files changed

Lines changed: 304 additions & 186 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [3.6, 3.7, 3.8]
10+
python-version: [3.6, 3.7, 3.8, 3.9]
1111

1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Set up Python ${{ matrix.python-version }}
1515
uses: actions/setup-python@v2
1616
with:
1717
python-version: ${{ matrix.python-version }}
18-
18+
1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
2222
python -m pip install tox codecov pre-commit
23-
23+
2424
# Run tox using the version of Python in `PATH`
2525
- name: Run Tox
2626
run: tox -e py
27-
27+
2828
# Run pre-commit (only for python-3.7)
2929
- name: run pre-commit
3030
if: matrix.python-version == 3.7
3131
run: pre-commit run --all-files
32-
32+
3333
- name: Upload Results
3434
if: success()
3535
uses: codecov/codecov-action@v1
@@ -48,13 +48,13 @@ jobs:
4848
- name: Set up Python
4949
uses: actions/setup-python@v1
5050
with:
51-
python-version: "3.x"
52-
51+
python-version: "3.x"
52+
5353
- name: Install dependencies
5454
run: |
5555
python -m pip install --upgrade pip
5656
python -m pip install tox
57-
57+
5858
- name: Set tag version
5959
id: tag
6060
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
@@ -64,7 +64,7 @@ jobs:
6464
id: module
6565
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
6666
run: echo ::set-output name=version::$(python setup.py --version)
67-
67+
6868
- name: Build and publish
6969
if: steps.tag.outputs.tag == steps.module.outputs.version
7070
env:

.gitignore

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,103 @@
1-
*.pyc
2-
*~
3-
*.egg-info
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
412
build/
13+
develop-eggs/
514
dist/
6-
*.eggs
7-
MANIFEST
8-
.DS_Store
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
941
.coverage
42+
.coverage.*
1043
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
49+
# Translations
50+
*.mo
51+
*.pot
52+
53+
# Django stuff:
54+
*.log
55+
local_settings.py
56+
57+
# Flask stuff:
58+
instance/
59+
.webassets-cache
60+
61+
# Scrapy stuff:
62+
.scrapy
63+
64+
# Sphinx documentation
65+
docs/_build/
66+
67+
# PyBuilder
68+
target/
69+
70+
# Jupyter Notebook
71+
.ipynb_checkpoints
72+
73+
# pyenv
74+
.python-version
75+
76+
# celery beat schedule file
77+
celerybeat-schedule
78+
79+
# SageMath parsed files
80+
*.sage.py
81+
82+
# dotenv
83+
.env
84+
85+
# virtualenv
86+
.venv
87+
venv/
88+
ENV/
89+
90+
# Spyder project settings
91+
.spyderproject
92+
.spyproject
93+
94+
# Rope project settings
95+
.ropeproject
96+
97+
# mkdocs documentation
98+
/site
99+
100+
# mypy
101+
.mypy_cache/
102+
103+
.pytest_cache

.pre-commit-config.yaml

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
11
repos:
2-
-
3-
repo: https://github.com/pre-commit/mirrors-isort
4-
rev: v4.3.21
5-
hooks:
6-
- id: isort
7-
language_version: python3.7
8-
-
9-
repo: 'https://github.com/psf/black'
10-
rev: stable
11-
hooks:
12-
- id: black
13-
args: ['--safe']
14-
language_version: python3.7
15-
-
16-
repo: https://gitlab.com/PyCQA/flake8
17-
rev: 3.8.3
18-
hooks:
19-
- id: flake8
20-
language_version: python3.7
21-
args: [
22-
# E501 let black handle all line length decisions
23-
# W503 black conflicts with "line break before operator" rule
24-
# E203 black conflicts with "whitespace before ':'" rule
25-
'--ignore=E501,W503,E203']
26-
-
27-
repo: 'https://github.com/chewse/pre-commit-mirrors-pydocstyle'
28-
# 2.1.1
29-
rev: 22d3ccf6cf91ffce3b16caa946c155778f0cb20f
30-
hooks:
31-
- id: pydocstyle
32-
language_version: python3.7
33-
args: [
34-
# Check for docstring presence only
35-
'--select=D1',
36-
# Don't require docstrings for tests
37-
'--match=(?!test).*\.py']
2+
- repo: https://github.com/psf/black
3+
rev: 19.10b0
4+
hooks:
5+
- id: black
6+
language_version: python
387

39-
-
40-
repo: https://github.com/pre-commit/mirrors-mypy
41-
rev: 'v0.782'
42-
hooks:
43-
- id: mypy
44-
exclude: ^python_seed/template
45-
args: [--no-strict-optional, --ignore-missing-imports]
8+
- repo: https://github.com/PyCQA/isort
9+
rev: 5.4.2
10+
hooks:
11+
- id: isort
12+
language_version: python
13+
args: [
14+
'--project=python_seed',
15+
'--thirdparty=click',
16+
'--section-default=THIRDPARTY']
17+
18+
- repo: https://github.com/PyCQA/flake8
19+
rev: 3.8.3
20+
hooks:
21+
- id: flake8
22+
language_version: python
23+
args: [
24+
# E501 let black handle all line length decisions
25+
# W503 black conflicts with "line break before operator" rule
26+
# E203 black conflicts with "whitespace before ':'" rule
27+
'--ignore=E501,W503,E203',
28+
'--max-complexity=12',
29+
'--max-line-length=90']
30+
31+
- repo: https://github.com/PyCQA/pydocstyle
32+
rev: 5.1.1
33+
hooks:
34+
- id: pydocstyle
35+
language_version: python
36+
args: [
37+
# Check for docstring presence only
38+
'--select=D1',
39+
# Don't require docstrings for tests
40+
'--match=(?!test).*\.py']
41+
42+
- repo: https://github.com/pre-commit/mirrors-mypy
43+
rev: v0.812
44+
hooks:
45+
- id: mypy
46+
language_version: python
47+
exclude: ^python_seed/template
48+
args: [--no-strict-optional, --ignore-missing-imports]

CHANGES.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
1.1.0 (2021-05-07)
2+
------------------
3+
- update pre-commit config
4+
- add python3.9 in CI
5+
- add `setup.cfg` for linters
6+
- remove `pkg_resources` usage
7+
18
1.0.1 (2020-08-27)
2-
------------------------
9+
------------------
310
- add coverage.xml output from tox runs.
411

512
1.0.0.post2 (2020-08-21)

python_seed/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
"""python_seed."""
22

3-
import pkg_resources
4-
5-
version = pkg_resources.get_distribution(__package__).version
3+
__version__ = "1.0.1"

python_seed/scripts/cli.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
import shutil
55

66
import click
7-
import pkg_resources
87

9-
from .. import version
8+
from .. import __version__
9+
10+
try:
11+
from importlib.resources import files as resources_files # type: ignore
12+
except ImportError:
13+
# Try backported to PY<39 `importlib_resources`.
14+
from importlib_resources import files as resources_files # type: ignore
1015

1116

1217
@click.group(short_help="python-seed CLI")
13-
@click.version_option(version=version, message="%(version)s")
18+
@click.version_option(version=__version__, message="%(version)s")
1419
def pyseed():
1520
"""python-seed subcommands."""
1621
pass
@@ -23,18 +28,18 @@ def pyseed():
2328
)
2429
def create(name, ci):
2530
"""Create new python seed skeleton."""
26-
template_dir = pkg_resources.resource_filename("python_seed", "template/module")
27-
31+
template_dir = str(resources_files("python_seed") / "template" / "module")
32+
print(template_dir)
2833
shutil.copytree(template_dir, name)
2934

3035
if ci:
31-
template_dir = pkg_resources.resource_filename(
32-
"python_seed", f"template/ci/.{ci}"
36+
template_dir = str(
37+
resources_files("python_seed") / "template" / "ci" / f".{ci}"
3338
)
3439
shutil.copytree(template_dir, f"{name}/.{ci}")
3540

36-
covconfig = pkg_resources.resource_filename(
37-
"python_seed", "template/cov/codecov.yml"
41+
covconfig = str(
42+
resources_files("python_seed") / "template" / "cov" / "codecov.yml"
3843
)
3944
shutil.copy2(covconfig, f"{name}/codecov.yml")
4045

python_seed/template/ci/.circleci/config.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,35 @@ jobs:
4646
"python-3.6":
4747
<<: *common
4848
docker:
49-
- image: circleci/python:3.6.5
49+
- image: cimg/python:3.6.13
5050
environment:
5151
- TOXENV=py36
5252

5353
"python-3.7":
5454
<<: *common
5555
docker:
56-
- image: circleci/python:3.7.2
56+
- image: cimg/python:3.7.10
5757
environment:
5858
- TOXENV=py37
5959
- UPLOAD_COVERAGE=1
6060

6161
"python-3.8":
6262
<<: *common
6363
docker:
64-
- image: circleci/python:3.8.4
64+
- image: cimg/python:3.8.10
6565
environment:
6666
- TOXENV=py38
6767

68+
"python-3.9":
69+
<<: *common
70+
docker:
71+
- image: cimg/python:3.9.5
72+
environment:
73+
- TOXENV=py39
74+
6875
deploy:
6976
docker:
70-
- image: circleci/python:3.7.2
77+
- image: cimg/python:3.7.10
7178
environment:
7279
- TOXENV=release
7380
working_directory: ~/pyseed
@@ -99,6 +106,7 @@ workflows:
99106
tags:
100107
only: /.*/
101108
- "python-3.8"
109+
- "python-3.9"
102110
- deploy:
103111
requires:
104112
- "python-3.7"

0 commit comments

Comments
 (0)