Skip to content

Commit 425745f

Browse files
authored
Merge pull request #1 from ashb/modernize-project
Modernize project: Py3.6+, black, flynt, flake8, Github Actions
2 parents 8c592ff + 5e503a4 commit 425745f

File tree

20 files changed

+863
-759
lines changed

20 files changed

+863
-759
lines changed

.flake8

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- cfg -*-
2+
[flake8]
3+
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
4+
exclude = .git, .venv, docs/conf.py
5+
ignore =
6+
E722 ; do not use bare 'except'
7+
E741 ; ambiguous variable name
8+
W503 ; line break before binary operator -- conflicts with black formatting
9+
max-complexity = 30
10+
max-line-length = 160
11+
show-source = true
12+
pytest-fixture-no-parentheses = true

.github/workflows/test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
10+
env:
11+
PRE_COMMIT_COLOR: always
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: [3.6, 3.7, 3.8, 3.9]
20+
os: [ubuntu-latest]
21+
env:
22+
PYTHON: ${{ matrix.python-version }}
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Cache deps
30+
uses: actions/cache@v2
31+
with:
32+
path: |
33+
~/.cache/pypoetry/
34+
~/.cache/pip/
35+
key: python${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
36+
restore-keys: python${{ matrix.python-version }}-
37+
- name: Cache pre-commit deps
38+
uses: actions/cache@v2
39+
with:
40+
path: |
41+
~/.cache/pre-commit/
42+
key: precommit-${{ hashFiles('.pre-commit-config.yaml') }}
43+
restore-keys: precommit-
44+
- name: Install dependencies
45+
run: |
46+
python -m pip install --upgrade pip
47+
python -m pip install --upgrade poetry pre-commit
48+
poetry install
49+
- name: Lint
50+
run: |
51+
pre-commit run --all-files -v --show-diff-on-failure
52+
poetry run pytest --dead-fixtures --dup-fixtures --color=yes
53+
pre-commit gc
54+
- name: Test with pytest
55+
run: |
56+
make test args="--color=yes"
57+
- name: Upload coverage to Codecov
58+
uses: codecov/[email protected]
59+
with:
60+
flags: unittests
61+
env_vars: PYTHON

.pre-commit-config.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# To install the git pre-commit hook run:
2+
# pre-commit install
3+
# To update the pre-commit hooks run:
4+
# pre-commit install-hooks
5+
exclude: '^(\.bumpversion\.cfg)(/|$)'
6+
minimum_pre_commit_version: "1.20.0"
7+
repos:
8+
- repo: meta
9+
hooks:
10+
- id: identity
11+
- id: check-hooks-apply
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v3.4.0
14+
hooks:
15+
- id: check-merge-conflict
16+
- id: debug-statements
17+
- id: check-builtin-literals
18+
- id: detect-private-key
19+
- id: end-of-file-fixer
20+
- id: mixed-line-ending
21+
# - id: check-executables-have-shebangs
22+
- id: trailing-whitespace
23+
- id: fix-encoding-pragma
24+
args:
25+
- --remove
26+
- repo: https://github.com/asottile/pyupgrade
27+
rev: v2.18.1
28+
hooks:
29+
- id: pyupgrade
30+
args: ["--py36-plus"]
31+
- repo: https://github.com/ikamensh/flynt/
32+
rev: '0.63'
33+
hooks:
34+
- id: flynt
35+
- repo: local
36+
hooks:
37+
- id: mypy
38+
name: mypy
39+
language: system
40+
entry: poetry run mypy
41+
types: [python]
42+
exclude: ^docs/
43+
- id: black
44+
name: black
45+
language: system
46+
entry: poetry run black
47+
types: [python]
48+
exclude: ^docs/conf\.py$
49+
- id: flake8
50+
name: flake8
51+
language: system
52+
entry: poetry run flake8
53+
types: [python]
54+
exclude: ^docs/conf\.py$
55+
- id: isort
56+
name: isort
57+
language: system
58+
entry: poetry run isort
59+
types: [python]

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ build: ## Build the sdist/wheel packages
1515
poetry build
1616

1717
test: ## Test the project
18-
poetry run pytest --verbosity=2 --strict --log-level=DEBUG $(args)
18+
poetry run pytest --verbosity=2 --log-level=DEBUG $(args)
1919

2020
lint: ## Check code for style
21-
poetry run flake8 --statistics --show-source $(CODE) test/
22-
poetry run black --diff --check $(CODE) test/
21+
pre-commit run
2322
poetry run pytest --dead-fixtures --dup-fixtures
2423

2524
pretty: ## Prettify the code
2625
poetry run isort $(CODE) test/
2726
poetry run black $(CODE) test/
2827

2928
precommit_install: ## Install simple pre-commit checks
30-
echo -e '#!/bin/sh\nmake lint test\n' > .git/hooks/pre-commit
31-
chmod +x .git/hooks/pre-commit
29+
pre-commit install
3230

3331
bump_major: ## Release a new major version
3432
poetry version major

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
[![Build Status](https://travis-ci.org/ribozz/sphinx-argparse.svg?branch=master)](https://travis-ci.org/ribozz/sphinx-argparse)
21
[![Documentation Status](https://readthedocs.org/projects/sphinx-argparse/badge/?version=stable)](http://sphinx-argparse.readthedocs.org/)
32
[![PyPI version](https://badge.fury.io/py/sphinx-argparse.svg)](https://badge.fury.io/py/sphinx-argparse)
43
[![Install with conda](https://anaconda.org/conda-forge/sphinx-argparse/badges/installer/conda.svg)](https://github.com/conda-forge/sphinx-argparse-feedstock)

docs/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Change log
33
**********
44

5+
Unreleased
6+
##########
7+
8+
* Minimum python version is now 3.6
9+
510
0.3.1
611
#####
712

docs/conf.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# sphinx-argparse documentation build configuration file, created by
43
# sphinx-quickstart on Thu Jan 31 15:13:43 2013.
@@ -11,7 +10,8 @@
1110
# All configuration values have a default; values that are commented out
1211
# serve to show the default.
1312

14-
import sys, os
13+
import os
14+
import sys
1515

1616
# If extensions (or extra_modules to document with autodoc) are in another directory,
1717
# add these directories to sys.path here. If the directory is relative to the
@@ -51,8 +51,8 @@
5151
master_doc = 'index'
5252

5353
# General information about the project.
54-
project = u'sphinx-argparse'
55-
copyright = u'2017, Alex Rudakov, Devon Ryan and contributors'
54+
project = 'sphinx-argparse'
55+
copyright = '2017, Alex Rudakov, Devon Ryan and contributors'
5656

5757
# The version info for the project you're documenting, acts as replacement for
5858
# |version| and |release|, also used in various other places throughout the
@@ -61,6 +61,7 @@
6161
# The short X.Y version.
6262

6363
import pkg_resources # part of setuptools
64+
6465
version = pkg_resources.require("sphinx-argparse")[0].version
6566

6667
# The full version, including alpha/beta/rc tags.
@@ -197,8 +198,8 @@
197198
# Grouping the document tree into LaTeX files. List of tuples
198199
# (source start file, target name, title, author, documentclass [howto/manual]).
199200
latex_documents = [
200-
('index', 'sphinx-argparse.tex', u'sphinx-argparse Documentation',
201-
u'Alex Rudakov and Devon Ryan', 'manual'),
201+
('index', 'sphinx-argparse.tex', 'sphinx-argparse Documentation',
202+
'Alex Rudakov and Devon Ryan', 'manual'),
202203
]
203204

204205
# The name of an image file (relative to this directory) to place at the top of
@@ -227,8 +228,8 @@
227228
# One entry per manual page. List of tuples
228229
# (source start file, name, description, authors, manual section).
229230
man_pages = [
230-
('index', 'sphinx-argparse', u'sphinx-argparse Documentation',
231-
[u'Alex Rudakov', u'Devon Ryan'], 1)
231+
('index', 'sphinx-argparse', 'sphinx-argparse Documentation',
232+
['Alex Rudakov', 'Devon Ryan'], 1)
232233
]
233234

234235
# If true, show URL addresses after external links.
@@ -241,8 +242,8 @@
241242
# (source start file, target name, title, author,
242243
# dir menu entry, description, category)
243244
texinfo_documents = [
244-
('index', 'sphinx-argparse', u'sphinx-argparse Documentation',
245-
u'Alex Rudakov and Devon Ryan', 'sphinx-argparse', 'One line description of project.',
245+
('index', 'sphinx-argparse', 'sphinx-argparse Documentation',
246+
'Alex Rudakov and Devon Ryan', 'sphinx-argparse', 'One line description of project.',
246247
'Miscellaneous'),
247248
]
248249

docs/markdown.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ In addition to using MarkDown in nested content, one can also use MarkDown direc
8080
def blah():
8181
parser = argparse.ArgumentParser(description="""
8282
### Example of MarkDown inside programs
83-
83+
8484
[I'm a link](http://www.google.com)
8585
""")
8686
parser.add_argument('cmd', help='execute a `command`')
@@ -101,4 +101,3 @@ This will then be rendered as:
101101
:func: blah
102102
:prog: sample
103103
:markdownhelp:
104-

docs/sample.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Examples
44
Example documentation structure
55
-------------------------------
66

7-
Here is an example structure for the documentation of a complex command with many subcommands.
7+
Here is an example structure for the documentation of a complex command with many subcommands.
88
You are free to use any structure, but this may be a good starting point.
99

1010
File "index.rst"::

0 commit comments

Comments
 (0)