Skip to content

Commit 7824811

Browse files
authored
Merge pull request #1463 from JohnVillalovos/jlvillal/isort
chore: add isort as a checker
2 parents 1508eb7 + f3afd34 commit 7824811

Some content is hidden

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

96 files changed

+96
-143
lines changed

.github/workflows/lint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ jobs:
3232
run: tox -e pep8
3333
- name: Run mypy static typing checker (http://mypy-lang.org/)
3434
run: tox -e mypy
35+
- name: Run isort import order checker (https://pycqa.github.io/isort/)
36+
run: tox -e isort -- --check

gitlab/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@
3131
from gitlab.const import * # noqa: F401,F403
3232
from gitlab.exceptions import * # noqa: F401,F403
3333

34-
3534
warnings.filterwarnings("default", category=DeprecationWarning, module="^gitlab")

gitlab/__main__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import gitlab.cli
22

3-
43
if __name__ == "__main__":
54
gitlab.cli.main()

gitlab/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
from types import ModuleType
2020
from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type
2121

22-
from .client import Gitlab, GitlabList
2322
from gitlab import types as g_types
2423

24+
from .client import Gitlab, GitlabList
25+
2526
__all__ = [
2627
"RequiredOptional",
2728
"RESTObject",

gitlab/cli.py

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import gitlab.config
2929
from gitlab.base import RESTObject
3030

31-
3231
# This regex is based on:
3332
# https://github.com/jpvanhal/inflection/blob/master/inflection/__init__.py
3433
camel_upperlower_regex = re.compile(r"([A-Z]+)([A-Z][a-z])")

gitlab/client.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717
"""Wrapper for the GitLab API."""
1818

1919
import time
20-
from typing import cast, Any, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
20+
from typing import Any, cast, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
2121

2222
import requests
2323
import requests.utils
24+
from requests_toolbelt.multipart.encoder import MultipartEncoder # type: ignore
2425

2526
import gitlab.config
2627
import gitlab.const
2728
import gitlab.exceptions
2829
from gitlab import utils
29-
from requests_toolbelt.multipart.encoder import MultipartEncoder # type: ignore
30-
3130

3231
REDIRECT_MSG = (
3332
"python-gitlab detected an http to https redirection. You "
@@ -385,7 +384,6 @@ def _set_auth_info(self) -> None:
385384

386385
def enable_debug(self) -> None:
387386
import logging
388-
389387
from http.client import HTTPConnection # noqa
390388

391389
HTTPConnection.debuglevel = 1 # type: ignore

gitlab/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
import os
1918
import configparser
19+
import os
2020
import shlex
2121
import subprocess
22-
from typing import List, Optional, Union
2322
from os.path import expanduser, expandvars
23+
from typing import List, Optional, Union
2424

2525
from gitlab.const import USER_AGENT
2626

gitlab/const.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from gitlab.__version__ import __title__, __version__
1919

20-
2120
NO_ACCESS: int = 0
2221
MINIMAL_ACCESS: int = 5
2322
GUEST_ACCESS: int = 10

gitlab/exceptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
import functools
19-
from typing import Any, Callable, cast, Optional, Type, TypeVar, TYPE_CHECKING, Union
19+
from typing import Any, Callable, cast, Optional, Type, TYPE_CHECKING, TypeVar, Union
2020

2121

2222
class GitlabError(Exception):

gitlab/mixins.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
import warnings
1819
from types import ModuleType
1920
from typing import (
2021
Any,
@@ -31,12 +32,10 @@
3132
import requests
3233

3334
import gitlab
34-
from gitlab import base
35-
from gitlab import cli
35+
from gitlab import base, cli
3636
from gitlab import exceptions as exc
3737
from gitlab import types as g_types
3838
from gitlab import utils
39-
import warnings
4039

4140
__all__ = [
4241
"GetMixin",

gitlab/tests/conftest.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
23
import gitlab
34

45

gitlab/tests/mixins/test_meta_mixins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
GetMixin,
66
ListMixin,
77
NoUpdateMixin,
8-
UpdateMixin,
98
RetrieveMixin,
9+
UpdateMixin,
1010
)
1111

1212

gitlab/tests/mixins/test_mixin_methods.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pytest
2-
32
from httmock import HTTMock, response, urlmatch # noqa
43

54
from gitlab import base

gitlab/tests/objects/test_appearance.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66
import responses
77

8-
98
title = "GitLab Test Instance"
109
description = "gitlab-test.example.com"
1110
new_title = "new-title"

gitlab/tests/objects/test_applications.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66
import responses
77

8-
98
title = "GitLab Test Instance"
109
description = "gitlab-test.example.com"
1110
new_title = "new-title"

gitlab/tests/objects/test_badges.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88
import responses
99

10-
from gitlab.v4.objects import ProjectBadge, GroupBadge
10+
from gitlab.v4.objects import GroupBadge, ProjectBadge
1111

1212
link_url = (
1313
"http://example.com/ci_status.svg?project=example-org/example-project&ref=master"

gitlab/tests/objects/test_deploy_tokens.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from gitlab.v4.objects import ProjectDeployToken
88

9-
109
create_content = {
1110
"id": 1,
1211
"name": "test_deploy_token",

gitlab/tests/objects/test_job_artifacts.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66
import responses
77

8-
98
ref_name = "master"
109
job = "build"
1110

gitlab/tests/objects/test_jobs.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from gitlab.v4.objects import ProjectJob
88

9-
109
job_content = {
1110
"commit": {
1211
"author_email": "admin@example.com",

gitlab/tests/objects/test_packages.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from gitlab.v4.objects import GroupPackage, ProjectPackage, ProjectPackageFile
1010

11-
1211
package_content = {
1312
"id": 1,
1413
"name": "com/mycompany/my-app",

gitlab/tests/objects/test_pipelines.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from gitlab.v4.objects import ProjectPipeline
88

9-
109
pipeline_content = {
1110
"id": 46,
1211
"project_id": 1,

gitlab/tests/objects/test_project_merge_request_approvals.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import gitlab
1111

12-
1312
approval_rule_id = 1
1413
approval_rule_name = "security"
1514
approvals_required = 3

gitlab/tests/objects/test_projects.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from gitlab.v4.objects import Project
99

10-
1110
project_content = {"name": "name", "id": 1}
1211
import_content = {
1312
"id": 1,

gitlab/tests/objects/test_resource_label_events.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import responses
77

88
from gitlab.v4.objects import (
9+
GroupEpicResourceLabelEvent,
910
ProjectIssueResourceLabelEvent,
1011
ProjectMergeRequestResourceLabelEvent,
11-
GroupEpicResourceLabelEvent,
1212
)
1313

1414

gitlab/tests/objects/test_resource_state_events.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
ProjectMergeRequestResourceStateEvent,
1111
)
1212

13-
1413
issue_event_content = {"id": 1, "resource_type": "Issue"}
1514
mr_event_content = {"id": 1, "resource_type": "MergeRequest"}
1615

gitlab/tests/objects/test_runners.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import gitlab
77

8-
98
runner_detail = {
109
"active": True,
1110
"architecture": "amd64",

gitlab/tests/objects/test_snippets.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pytest
77
import responses
88

9-
109
title = "Example Snippet Title"
1110
visibility = "private"
1211
new_title = "new-title"

gitlab/tests/objects/test_todos.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from gitlab.v4.objects import Todo
1212

13-
1413
with open(os.path.dirname(__file__) + "/../data/todo.json", "r") as json_file:
1514
todo_content = json_file.read()
1615
json_content = json.loads(todo_content)

gitlab/tests/objects/test_variables.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from gitlab.v4.objects import GroupVariable, ProjectVariable, Variable
1414

15-
1615
key = "TEST_VARIABLE_1"
1716
value = "TEST_1"
1817
new_value = "TEST_2"

gitlab/tests/test_base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
import pickle
1919

20-
from gitlab import base
2120
import pytest
2221

22+
from gitlab import base
23+
2324

2425
class FakeGitlab(object):
2526
pass

gitlab/tests/test_cli.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

1919
import argparse
20+
import io
2021
import os
2122
import tempfile
22-
import io
23-
2423
from contextlib import redirect_stderr # noqa: H302
2524

2625
import pytest

gitlab/tests/test_config.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
import io
1819
import os
1920
from textwrap import dedent
2021

2122
import mock
22-
import io
23-
24-
from gitlab import config, USER_AGENT
2523
import pytest
2624

25+
from gitlab import config, USER_AGENT
2726

2827
custom_user_agent = "my-package/1.0.0"
2928

gitlab/tests/test_gitlab.py

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from gitlab import Gitlab, GitlabList, USER_AGENT
2525
from gitlab.v4.objects import CurrentUser
2626

27-
2827
username = "username"
2928
user_id = 1
3029

gitlab/tests/test_gitlab_http_methods.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
import requests
3-
4-
from httmock import HTTMock, urlmatch, response
3+
from httmock import HTTMock, response, urlmatch
54

65
from gitlab import GitlabHttpError, GitlabList, GitlabParsingError
76

gitlab/v4/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
import gitlab
2424
import gitlab.base
25-
from gitlab import cli
2625
import gitlab.v4.objects
26+
from gitlab import cli
2727

2828

2929
class GitlabCLI(object):

gitlab/v4/objects/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
from .container_registry import *
3030
from .custom_attributes import *
3131
from .deploy_keys import *
32-
from .deployments import *
3332
from .deploy_tokens import *
33+
from .deployments import *
3434
from .discussions import *
3535
from .environments import *
3636
from .epics import *
@@ -54,6 +54,7 @@
5454
from .notification_settings import *
5555
from .packages import *
5656
from .pages import *
57+
from .personal_access_tokens import *
5758
from .pipelines import *
5859
from .projects import *
5960
from .push_rules import *
@@ -71,8 +72,6 @@
7172
from .users import *
7273
from .variables import *
7374
from .wikis import *
74-
from .personal_access_tokens import *
75-
7675

7776
# TODO: deprecate these in favor of gitlab.const.*
7877
VISIBILITY_PRIVATE = "private"

gitlab/v4/objects/access_requests.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
ObjectDeleteMixin,
88
)
99

10-
1110
__all__ = [
1211
"GroupAccessRequest",
1312
"GroupAccessRequestManager",

gitlab/v4/objects/appearance.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from gitlab.base import RequiredOptional, RESTManager, RESTObject
33
from gitlab.mixins import GetWithoutIdMixin, SaveMixin, UpdateMixin
44

5-
65
__all__ = [
76
"ApplicationAppearance",
87
"ApplicationAppearanceManager",

gitlab/v4/objects/award_emojis.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from gitlab.base import RequiredOptional, RESTManager, RESTObject
22
from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin
33

4-
54
__all__ = [
65
"ProjectIssueAwardEmoji",
76
"ProjectIssueAwardEmojiManager",

0 commit comments

Comments
 (0)