Skip to content

Commit f42fc9e

Browse files
Add automatic checks of the pep8 using flake8 and Github Actions
Like fogleman#35, I believe that project is a great educational tool, an impressive achievement, and a reference for clean Python code. Warnings F403 and F405 are currently ignored. That could be removed when fogleman#124 is merged. Warnings E128,E201,E226,E231 could be removed if autopep8 or similar is used. I advise to merge fogleman#124 before, to limit the risk of merge conflict. I fixed 3 small pep8 issues in main.py too.
1 parent e311522 commit f42fc9e

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

.github/workflows/python-linting.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Flake8 Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
flake8-lint:
7+
runs-on: ubuntu-latest
8+
name: Lint
9+
steps:
10+
- name: Check out source repository
11+
uses: actions/checkout@v2
12+
- name: Set up Python environment
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: "3.6"
16+
- name: flake8 Lint
17+
uses: py-actions/flake8@v1
18+

main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
FLYING_SPEED = 15
2121

2222
GRAVITY = 20.0
23-
MAX_JUMP_HEIGHT = 1.0 # About the height of a block.
23+
MAX_JUMP_HEIGHT = 1.0 # About the height of a block.
2424
# To derive the formula for calculating jump speed, first solve
2525
# v_t = v_0 + a * t
2626
# for the time at which you achieve maximum height, where a is the acceleration
@@ -36,6 +36,7 @@
3636
if sys.version_info[0] >= 3:
3737
xrange = range
3838

39+
3940
def cube_vertices(x, y, z, n):
4041
""" Return the vertices of the cube at position x, y, z with size 2*n.
4142
@@ -592,7 +593,7 @@ def _update(self, dt):
592593
"""
593594
# walking
594595
speed = FLYING_SPEED if self.flying else WALKING_SPEED
595-
d = dt * speed # distance covered this tick.
596+
d = dt * speed # distance covered this tick.
596597
dx, dy, dz = self.get_motion_vector()
597598
# New position in space, before accounting for gravity.
598599
dx, dy, dz = dx * d, dy * d, dz * d

setup.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[metadata]
2+
description-file = README.md
3+
4+
[flake8]
5+
max-line-length = 100
6+
extend-exclude = env/*
7+
ignore =
8+
E128,E201,E226,E231 # FIXME: use autopep8 on main.py
9+
F403,F405 # FIXME: Can be removed when #124 is merged

0 commit comments

Comments
 (0)