8000 Merge pull request #1397 from JohnVillalovos/jlvillal/flake8 · tzheng-splunk/python-gitlab@976e14d · GitHub
[go: up one dir, main page]

Skip to content

Commit 976e14d

Browse files
authored
Merge pull request python-gitlab#1397 from JohnVillalovos/jlvillal/flake8
Fix all issues reported by running: tox -e pep8 and enable pep8 as a linter check
2 parents 5fac07a + 40f4ab2 commit 976e14d

33 files changed

+149
-157
lines changed

.github/workflows/lint.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ env:
1212
PY_COLORS: 1
1313

1414
jobs:
15-
black:
16-
runs-on: ubuntu-latest
17-
steps:
18-
- uses: actions/checkout@v2
19-
- uses: actions/setup-python@v2
20-
- uses: psf/black@stable
21-
with:
22-
black_args: ". --check"
2315
commitlint:
2416
runs-on: ubuntu-latest
2517
steps:
@@ -28,10 +20,15 @@ jobs:
2820
fetch-depth: 0
2921
- uses: wagoid/commitlint-github-action@v3
3022

31-
mypy:
23+
linters:
3224
runs-on: ubuntu-latest
3325
steps:
3426
- uses: actions/checkout@v2
3527
- uses: actions/setup-python@v2
3628
- run: pip install --upgrade tox
37-
- run: tox -e mypy
29+
- name: Run black code formatter (https://black.readthedocs.io/en/stable/)
30+
run: tox -e black -- --check
31+
- name: Run flake8 (https://flake8.pycqa.org/en/latest/)
32+
run: tox -e pep8
33+
- name: Run mypy static typing checker (http://mypy-lang.org/)
34+
run: tox -e mypy

gitlab/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818

1919
import warnings
2020

21-
import gitlab.config
22-
from gitlab.__version__ import (
21+
import gitlab.config # noqa: F401
22+
from gitlab.__version__ import ( # noqa: F401
2323
__author__,
2424
__copyright__,
2525
__email__,
2626
__license__,
2727
__title__,
2828
__version__,
2929
)
30-
from gitlab.client import Gitlab, GitlabList
31-
from gitlab.const import * # noqa
32-
from gitlab.exceptions import * # noqa
30+
from gitlab.client import Gitlab, GitlabList # noqa: F401
31+
from gitlab.const import * # noqa: F401,F403
32+
from gitlab.exceptions import * # noqa: F401,F403
3333

3434

3535
warnings.filterwarnings("default", category=DeprecationWarning, module="^gitlab")

gitlab/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import sys
2424
from typing import Any, Callable, Dict, Optional, Tuple, Union
2525

26-
import gitlab.config
26+
import gitlab.config # noqa: F401
2727

2828
camel_re = re.compile("(.)([A-Z])")
2929

@@ -162,7 +162,6 @@ def docs() -> argparse.ArgumentParser:
162162
if "sphinx" not in sys.modules:
163163
sys.exit("Docs parser is only intended for build_sphinx")
164164

165-
parser = _get_base_parser(add_help=False)
166165
# NOTE: We must delay import of gitlab.v4.cli until now or
167166
# otherwise it will cause circular import errors
168167
import gitlab.v4.cli

gitlab/mixins.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
Dict,
2323
List,
2424
Optional,
25-
Tuple,
2625
Type,
2726
TYPE_CHECKING,
2827
Union,

gitlab/tests/mixins/test_mixin_methods.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def resp_cont(url, request):
4444

4545

4646
def test_refresh_mixin(gl):
47-
class O(RefreshMixin, FakeObject):
47+
class TestClass(RefreshMixin, FakeObject):
4848
pass
4949

5050
@urlmatch(scheme="http", netloc="localhost", path="/api/v4/tests/42", method="get")
@@ -55,7 +55,7 @@ def resp_cont(url, request):
5555

5656
with HTTMock(resp_cont):
5757
mgr = FakeManager(gl)
58-
obj = O(mgr, {"id": 42})
58+
obj = TestClass(mgr, {"id": 42})
5959
res = obj.refresh()
6060
assert res is None
6161
assert obj.foo == "bar"
@@ -265,7 +265,7 @@ def test_save_mixin(gl):
265265
class M(UpdateMixin, FakeManager):
266266
pass
267267

268-
class O(SaveMixin, base.RESTObject):
268+
class TestClass(SaveMixin, base.RESTObject):
269269
pass
270270

271271
@urlmatch(scheme="http", netloc="localhost", path="/api/v4/tests/42", method="put")
@@ -276,7 +276,7 @@ def resp_cont(url, request):
276276

277277
with HTTMock(resp_cont):
278278
mgr = M(gl)
279-
obj = O(mgr, {"id": 42, "foo": "bar"})
279+
obj = TestClass(mgr, {"id": 42, "foo": "bar"})
280280
obj.foo = "baz"
281281
obj.save()
282282
assert obj._attrs["foo"] == "baz"

gitlab/tests/mixins/test_object_mixins_attributes.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,35 @@
2727

2828

2929
def test_access_request_mixin():
30-
class O(AccessRequestMixin):
30+
class TestClass(AccessRequestMixin):
3131
pass
3232

33-
obj = O()
33+
obj = TestClass()
3434
assert hasattr(obj, "approve")
3535

3636

3737
def test_subscribable_mixin():
38-
class O(SubscribableMixin):
38+
class TestClass(SubscribableMixin):
3939
pass
4040

41-
obj = O()
41+
obj = TestClass()
4242
assert hasattr(obj, "subscribe")
4343
assert hasattr(obj, "unsubscribe")
4444

4545

4646
def test_todo_mixin():
47-
class O(TodoMixin):
47+
class TestClass(TodoMixin):
4848
pass
4949

50-
obj = O()
50+
obj = TestClass()
5151
assert hasattr(obj, "todo")
5252

5353

5454
def test_time_tracking_mixin():
55-
class O(TimeTrackingMixin):
55+
class TestClass(TimeTrackingMixin):
5656
pass
5757

58-
obj = O()
58+
obj = TestClass()
5959
assert hasattr(obj, "time_stats")
6060
assert hasattr(obj, "time_estimate")
6161
assert hasattr(obj, "reset_time_estimate")
@@ -64,16 +64,16 @@ class O(TimeTrackingMixin):
6464

6565

6666
def test_set_mixin():
67-
class O(SetMixin):
67+
class TestClass(SetMixin):
6868
pass
6969

70-
obj = O()
70+
obj = TestClass()
7171
assert hasattr(obj, "set")
7272

7373

7474
def test_user_agent_detail_mixin():
75-
class O(UserAgentDetailMixin):
75+
class TestClass(UserAgentDetailMixin):
7676
pass
7777

78-
obj = O()
78+
obj = TestClass()
7979
assert hasattr(obj, "user_agent_detail")

gitlab/tests/objects/test_appearance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ def test_get_update_appearance(gl, resp_application_appearance):
6363

6464

6565
def test_update_appearance(gl, resp_application_appearance):
66-
resp = gl.appearance.update(title=new_title, description=new_description)
66+< 10000 div class="diff-text-inner"> gl.appearance.update(title=new_title, description=new_description)

gitlab/tests/objects/test_bridges.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""
22
GitLab API: https://docs.gitlab.com/ee/api/jobs.html#list-pipeline-bridges
33
"""
4-
import re
5-
64
import pytest
75
import responses
86

9-
from gitlab.v4.objects import Project, ProjectPipelineBridge
7+
from gitlab.v4.objects import ProjectPipelineBridge
108

119

1210
@pytest.fixture

gitlab/tests/objects/test_project_merge_request_approvals.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_project_approval_manager_update_uses_post(project, resp_snippet):
241241
assert isinstance(
242242
approvals, gitlab.v4.objects.merge_request_approvals.ProjectApprovalManager
243243
)
244-
assert approvals._update_uses_post == True
244+
assert approvals._update_uses_post is True
245245

246246

247247
def test_list_merge_request_approval_rules(project, resp_snippet):
@@ -257,7 +257,7 @@ def test_update_merge_request_approvals_set_approvers(project, resp_snippet):
257257
approvals,
258258
gitlab.v4.objects.merge_request_approvals.ProjectMergeRequestApprovalManager,
259259
)
260-
assert approvals._update_uses_post == True
260+
assert approvals._update_uses_post is True
261261
response = approvals.set_approvers(
262262
updated_approval_rule_approvals_required,
263263
approver_ids=updated_approval_rule_user_ids,
@@ -277,7 +277,7 @@ def test_create_merge_request_approvals_set_approvers(project, resp_snippet):
277277
approvals,
278278
gitlab.v4.objects.merge_request_approvals.ProjectMergeRequestApprovalManager,
279279
)
280-
assert approvals._update_uses_post == True
280+
assert approvals._update_uses_post is True
281281
response = approvals.set_approvers(
282282
new_approval_rule_approvals_required,
283283
approver_ids=new_approval_rule_user_ids,

gitlab/tests/objects/test_runners.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,31 +200,31 @@ def resp_runner_verify():
200200

201201
def test_owned_runners_list(gl: gitlab.Gitlab, resp_get_runners_list):
202202
runners = gl.runners.list()
203-
assert runners[0].active == True
203+
assert runners[0].active is True
204204
assert runners[0].id == 6
205205
assert runners[0].name == "test-name"
206206
assert len(runners) == 1
207207

208208

209209
def test_project_runners_list(gl: gitlab.Gitlab, resp_get_runners_list):
210210
runners = gl.projects.get(1, lazy=True).runners.list()
211-
assert runners[0].active == True
211+
assert runners[0].active is True
212212
assert runners[0].id == 6
213213
assert runners[0].name == "test-name"
214214
assert len(runners) == 1
215215

216216

217217
def test_group_runners_list(gl: gitlab.Gitlab, resp_get_runners_list):
218218
runners = gl.groups.get(1, lazy=True).runners.list()
219-
assert runners[0].active == True
219+
assert runners[0].active is True
220220
assert runners[0].id == 6
221221
assert runners[0].name == "test-name"
222222
assert len(runners) == 1
223223

224224

225225
def test_all_runners_list(gl: gitlab.Gitlab, resp_get_runners_list):
226226
runners = gl.runners.all()
227-
assert runners[0].active == True
227+
assert runners[0].active is True
228228
assert runners[0].id == 6
229229
assert runners[0].name == "test-name"
230230
assert len(runners) == 1
@@ -238,7 +238,7 @@ def test_create_runner(gl: gitlab.Gitlab, resp_runner_register):
238238

239239
def test_get_update_runner(gl: gitlab.Gitlab, resp_runner_detail):
240240
runner = gl.runners.get(6)
241-
assert runner.active == True
241+
assert runner.active is True
242242
runner.tag_list.append("new")
243243
runner.save()
244244

@@ -259,14 +259,14 @@ def test_disable_group_runner(gl: gitlab.Gitlab, resp_runner_disable):
259259

260260
def test_enable_project_runner(gl: gitlab.Gitlab, resp_runner_enable):
261261
runner = gl.projects.get(1, lazy=True).runners.create({"runner_id": 6})
262-
assert runner.active == True
262+
assert runner.active is True
263263
assert runner.id == 6
264264
assert runner.name == "test-name"
265265

266266

267267
def test_enable_group_runner(gl: gitlab.Gitlab, resp_runner_enable):
268268
runner = gl.groups.get(1, lazy=True).runners.create({"runner_id": 6})
269-
assert runner.active == True
269+
assert runner.active is True
270270
assert runner.id == 6
271271
assert runner.name == "test-name"
272272

0 commit comments

Comments
 (0)
0