Skip to content

Commit 8336007

Browse files
committed
Split linting and packaging workflows.
Fix minor Flake8 warnings. Add an isort config to the example directory so that the tcod import is treated correctly.
1 parent 1d7479a commit 8336007

File tree

6 files changed

+64
-22
lines changed

6 files changed

+64
-22
lines changed

.github/workflows/python-lint.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Lint
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-20.04
11+
env:
12+
python-version: '3.9'
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Checkout submodules
17+
run: |
18+
git submodule update --init --recursive --depth 1
19+
- name: Set up Python ${{ env.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ env.python-version }}
23+
- name: Install Python dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
python -m pip install flake8 mypy black isort
27+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
- name: Fake initialize package
29+
run: |
30+
echo '__version__ = ""' > tcod/version.py
31+
- name: Flake8
32+
uses: liskin/gh-problem-matcher-wrap@v1
33+
with:
34+
linters: flake8
35+
run: flake8 tcod/
36+
- name: MyPy
37+
if: always()
38+
uses: liskin/gh-problem-matcher-wrap@v1
39+
with:
40+
linters: mypy
41+
run: mypy --show-column-numbers tcod/
42+
- name: isort
43+
uses: liskin/gh-problem-matcher-wrap@v1
44+
with:
45+
linters: isort
46+
run: isort tcod/ tests/ --check
47+
- name: isort (examples)
48+
uses: liskin/gh-problem-matcher-wrap@v1
49+
with:
50+
linters: isort
51+
run: isort examples/ --check --thirdparty tcod
52+
- name: Black
53+
run: |
54+
black --check tcod/

.github/workflows/python-package.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,11 @@ jobs:
4242
- name: Install Python dependencies
4343
run: |
4444
python -m pip install --upgrade pip
45-
python -m pip install flake8 mypy pytest pytest-cov pytest-benchmark black isort wheel
45+
python -m pip install pytest pytest-cov pytest-benchmark wheel
4646
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
4747
- name: Initialize package
4848
run: |
4949
python setup.py check # Creates tcod/version.py.
50-
- name: Lint with flake8
51-
run: |
52-
# stop the build if there are Python syntax errors or undefined names
53-
flake8 tcod/ --count --select=E9,F63,F7,F82 --show-source --statistics
54-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
55-
flake8 tcod/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
56-
- name: Check type hints with MyPy
57-
if: ${{ matrix.python-version != '3.6' }}
58-
run: |
59-
mypy tcod/
60-
- name: Check formatting with Black
61-
run: |
62-
black --check tcod/
63-
- name: Check import order
64-
run: |
65-
isort tcod/ --check --diff
66-
isort tests/ --check --diff
67-
isort examples/ --check --diff --thirdparty tcod
6850
- name: Build package.
6951
run: |
7052
python setup.py build sdist develop bdist_wheel --py-limited-api cp36 # Install the package in-place.

examples/.isort.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[isort]
2+
profile= black
3+
py_version = 36
4+
skip_gitignore = true
5+
line_length = 79

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ filterwarnings =
2020

2121
[flake8]
2222
ignore = E203 W503
23+
max-line-length = 120
2324

2425
[mypy]
2526
python_version = 3.6

tcod/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import tcod
5757
import tcod.event
5858
import tcod.tileset
59-
from tcod._internal import _check, _check_warn, deprecate, pending_deprecate
59+
from tcod._internal import _check, _check_warn, pending_deprecate
6060
from tcod.loader import ffi, lib
6161

6262
__all__ = (

tcod/libtcodpy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ def console_hline(
16281628
con: tcod.console.Console,
16291629
x: int,
16301630
y: int,
1631-
l: int,
1631+
l: int, # noqa: E741
16321632
flag: int = BKGND_DEFAULT,
16331633
) -> None:
16341634
"""Draw a horizontal line on the console.
@@ -1646,7 +1646,7 @@ def console_vline(
16461646
con: tcod.console.Console,
16471647
x: int,
16481648
y: int,
1649-
l: int,
1649+
l: int, # noqa: E741
16501650
flag: int = BKGND_DEFAULT,
16511651
) -> None:
16521652
"""Draw a vertical line on the console.

0 commit comments

Comments
 (0)