Skip to content

Commit 1966aab

Browse files
authored
Merge pull request #95 from akx/blacken-flake8
Flake8 fixes
2 parents 6fb204c + 2832c1b commit 1966aab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+289
-172
lines changed

.github/workflows/main.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
name: test
22

3-
on:
3+
on:
44
- push
55
- pull_request
66

77
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Setup Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.9
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip setuptools wheel
19+
python -m pip install -r requirements-dev.txt
20+
- name: Run flake8
21+
run: flake8
22+
- uses: actions/cache@v2
23+
with:
24+
path: ~/.cache/pip
25+
key: ${{ runner.os }}-pip
826
build:
927
runs-on: ubuntu-latest
1028
strategy:
@@ -26,7 +44,7 @@ jobs:
2644
with:
2745
path: ~/.cache/pip
2846
key: ${{ runner.os }}-pip
29-
47+
3048
deploy:
3149
name: Build deploy
3250
runs-on: ubuntu-latest
@@ -39,4 +57,3 @@ jobs:
3957
build: true
4058
# only upload if a tag is pushed (otherwise just build & check)
4159
upload: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }}
42-

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
line-length = 99
33
target-version = ['py36']
44
skip-string-normalization = true
5+
6+
[tool.isort]
7+
profile = "black"
8+
multi_line_output = 3

requirements-dev.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
black~=21.4b1; platform_python_implementation != "PyPy"
22
flake8
3+
flake8-bandit
4+
flake8-black; platform_python_implementation != "PyPy"
5+
flake8-bugbear
36
flake8-docstrings
7+
flake8-isort
8+
flake8-pytest
49
hacking
10+
isort
511
mock
612
pip-tools
713
pytest

requirements-dev.txt

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77
appdirs==1.4.4
88
# via black
99
attrs==20.3.0
10-
# via pytest
10+
# via
11+
# flake8-bugbear
12+
# pytest
13+
bandit==1.7.0
14+
# via flake8-bandit
1115
black==21.4b1 ; platform_python_implementation != "PyPy"
12-
# via -r requirements-dev.in
16+
# via
17+
# -r requirements-dev.in
18+
# flake8-black
1319
certifi==2020.12.5
1420
# via requests
1521
chardet==4.0.0
@@ -21,19 +27,45 @@ click==7.1.2
2127
# safety
2228
dparse==0.5.1
2329
# via safety
30+
flake8-bandit==2.1.2
31+
# via -r requirements-dev.in
32+
flake8-black==0.2.1 ; platform_python_implementation != "PyPy"
33+
# via -r requirements-dev.in
34+
flake8-bugbear==21.4.3
35+
# via -r requirements-dev.in
2436
flake8-docstrings==1.6.0
2537
# via -r requirements-dev.in
38+
flake8-isort==4.0.0
39+
# via -r requirements-dev.in
40+
flake8-polyfill==1.0.2
41+
# via flake8-bandit
42+
flake8-pytest==1.3
43+
# via -r requirements-dev.in
2644
flake8==3.8.4
2745
# via
2846
# -r requirements-dev.in
47+
# flake8-bandit
48+
# flake8-black
49+
# flake8-bugbear
2950
# flake8-docstrings
51+
# flake8-isort
52+
# flake8-polyfill
53+
# flake8-pytest
3054
# hacking
55+
gitdb==4.0.7
56+
# via gitpython
57+
gitpython==3.1.14
58+
# via bandit
3159
hacking==4.1.0
3260
# via -r requirements-dev.in
3361
idna==2.10
3462
# via requests
3563
iniconfig==1.1.1
3664
# via pytest
65+
isort==5.8.0
66+
# via
67+
# -r requirements-dev.in
68+
# flake8-isort
3769
mccabe==0.6.1
3870
# via flake8
3971
mock==4.0.3
@@ -47,6 +79,8 @@ packaging==20.9
4779
# safety
4880
pathspec==0.8.1
4981
# via black
82+
pbr==5.6.0
83+
# via stevedore
5084
pep517==0.10.0
5185
# via pip-tools
5286
pip-tools==6.1.0
@@ -56,7 +90,9 @@ pluggy==0.13.1
5690
py==1.10.0
5791
# via pytest
5892
pycodestyle==2.6.0
59-
# via flake8
93+
# via
94+
# flake8
95+
# flake8-bandit
6096
pydocstyle==6.0.0
6197
# via flake8-docstrings
6298
pyflakes==2.2.0
@@ -66,7 +102,9 @@ pyparsing==2.4.7
66102
pytest==6.2.3
67103
# via -r requirements-dev.in
68104
pyyaml==5.4.1
69-
# via dparse
105+
# via
106+
# bandit
107+
# dparse
70108
regex==2021.4.4
71109
# via black
72110
requests==2.25.1
@@ -78,9 +116,17 @@ responses==0.13.2
78116
safety==1.10.3
79117
# via -r requirements-dev.in
80118
six==1.15.0
81-
# via responses
119+
# via
120+
# bandit
121+
# responses
122+
smmap==4.0.0
123+
# via gitdb
82124
snowballstemmer==2.1.0
83125
# via pydocstyle
126+
stevedore==3.3.0
127+
# via bandit
128+
testfixtures==6.17.1
129+
# via flake8-isort
84130
toml==0.10.2
85131
# via
86132
# black

setup.cfg

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,37 @@ packages =
2323

2424
[bdist_wheel]
2525
universal = 1
26+
27+
[flake8]
28+
max-line-length = 99
29+
extend-ignore =
30+
# ignore line length problems; those are fixed by black
31+
E501
32+
# via black
33+
E203
34+
W503
35+
# docstring format leniency
36+
D100
37+
D104
38+
D105
39+
D200
40+
D202
41+
D205
42+
D400
43+
D401
44+
D403
45+
# things from `hacking` we don't care about
46+
H101
47+
H301
48+
H306
49+
H404
50+
H405
51+
per-file-ignores =
52+
test/*: D101,D102,D103,F841,S101,S106,B011
53+
# ignore "imported but not used" in any __init__.pys
54+
*/__init__.py: F401
55+
exclude =
56+
.git
57+
ENV
58+
__pycache__
59+
build

setup.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
#!/usr/bin/env python
2-
3-
from setuptools import setup
4-
import codecs
1+
import ast
52
import os.path
3+
import re
64

7-
8-
def read(rel_path):
9-
here = os.path.abspath(os.path.dirname(__file__))
10-
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
11-
return fp.read()
5+
from setuptools import setup
126

137

14-
def get_version(rel_path):
15-
for line in read(rel_path).splitlines():
16-
if line.startswith('__version__'):
17-
delim = '"' if '"' in line else "'"
18-
return line.split(delim)[1]
19-
else:
20-
raise RuntimeError("Unable to find version string.")
8+
def get_version(rel_path: str) -> str:
9+
"""
10+
Parse a version string from a __version__ = ... line in the given file.
11+
"""
12+
with open(os.path.join(os.path.dirname(__file__), rel_path)) as infp:
13+
match = re.search("__version__ = (.+?)$", infp.read(), re.M)
14+
if not match:
15+
raise ValueError("No version could be found")
16+
return ast.literal_eval(match.group(1))
2117

2218

2319
with open('README.md') as f:

test/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import json
22
import os
3-
import pytest
4-
import responses
53
import sys
64

5+
import pytest
6+
import responses
77

88
# make files under helpers available for import
99
HELPERS_PATH = os.path.join(os.path.dirname(__file__), 'helpers')

test/helpers/infra.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from upcloud_api import CloudManager, Storage, FirewallRule, Tag, IPAddress
1+
from upcloud_api.firewall import FirewallRule
2+
from upcloud_api.ip_address import IPAddress
23
from upcloud_api.server import Server, login_user_block
3-
4+
from upcloud_api.storage import Storage
5+
from upcloud_api.tag import Tag
46

57
CLUSTER = {
68
'web1': Server(

test/helpers/infra_helpers.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from upcloud_api import Tag
2-
3-
41
def create_cluster(manager, cluster):
52
"""Create all servers in cluster."""
63
for server in cluster:
@@ -30,7 +27,7 @@ def firewall_test(manager, firewall_rules, server):
3027
fs = server.get_firewall_rules()
3128
assert len(fs) == 2
3229

33-
for f in fs:
30+
for _ in fs:
3431
manager.delete_firewall_rule(server.uuid, 1)
3532

3633
fs = server.get_firewall_rules()

test/test_apidoc/test_10_ip_addresses.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from upcloud_api import IPAddress, Server
2-
from conftest import Mock, read_from_file
31
import json
4-
import responses
2+
3+
from conftest import read_from_file
4+
5+
from upcloud_api import IPAddress, Server
56

67

78
class TestIP:

0 commit comments

Comments
 (0)