Skip to content

Commit 58ec400

Browse files
authored
Migrate to pyproject.toml (#93)
* Migrate to pyproject.toml * Add flag "--check" in setup.py "black" command * Enable linting of "examples" * Sorted imports with isort * Fix pylint errors: missing imports * Merge setup.py black and isort into format command
1 parent 6959947 commit 58ec400

File tree

116 files changed

+487
-950
lines changed

Some content is hidden

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

116 files changed

+487
-950
lines changed

.github/workflows/kentik-api.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,26 @@ jobs:
3939
with:
4040
python-version: ${{ matrix.python-version }}
4141
architecture: x64
42-
- name: Install requirements
42+
- name: Install dependencies
4343
working-directory: ./kentik_api_library
44-
run: pip3 install -r requirements.txt
45-
- name: PyTest
44+
run: |
45+
set -xe
46+
python -VV
47+
python -m site
48+
python -m pip install --upgrade -r requirements.txt
49+
python -m pip install --upgrade -r requirements-dev.txt
50+
- name: Code formatting
4651
working-directory: ./kentik_api_library
47-
run: python3 setup.py pytest
48-
- name: Black
49-
uses: piotrpawlaczek/python-blacken@release/stable
50-
with:
51-
path: './kentik_api_library'
52-
line-length: '120'
52+
run: python3 setup.py format --check
53+
- name: Mypy
54+
working-directory: ./kentik_api_library
55+
run: python3 setup.py mypy
5356
- name: PyLint
5457
working-directory: ./kentik_api_library
5558
run: python3 setup.py pylint
56-
- name: Mypy
59+
- name: PyTest
5760
working-directory: ./kentik_api_library
58-
run: python3 setup.py mypy
61+
run: python3 setup.py pytest
5962

6063
build:
6164
needs: python-versions-setup

kentik_api_library/.pylintrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

kentik_api_library/examples/alerting_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
from datetime import datetime
88

9-
from kentik_api import KentikAPI, ManualMitigation, AlertFilter
9+
from kentik_api import AlertFilter, KentikAPI, ManualMitigation
1010
from kentik_api.utils import get_credentials
1111

1212
logging.basicConfig(level=logging.INFO)

kentik_api_library/examples/applications_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"""
55

66
import logging
7-
from kentik_api import KentikAPI, CustomApplication
7+
8+
from kentik_api import CustomApplication, KentikAPI
89
from kentik_api.utils import get_credentials
910

1011
logging.basicConfig(level=logging.INFO)

kentik_api_library/examples/batch_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"""
44

55
import logging
6-
from kentik_api import KentikAPI, Criterion, Upsert, Deletion, BatchOperationPart
6+
7+
from kentik_api import BatchOperationPart, Criterion, Deletion, KentikAPI, Upsert
78
from kentik_api.utils import get_credentials
89

910
logging.basicConfig(level=logging.INFO)

kentik_api_library/examples/bulk_user_create.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33

44
import yaml
5+
56
import kentik_api
67

78

kentik_api_library/examples/devices_example.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
import logging
77

8-
from kentik_api.public.types import ID
98
from kentik_api import (
10-
KentikAPI,
11-
Device,
12-
SNMPv3Conf,
139
AuthenticationProtocol,
14-
PrivacyProtocol,
15-
DeviceSubtype,
1610
CDNAttribute,
11+
Device,
12+
DeviceSubtype,
1713
Interface,
14+
KentikAPI,
15+
PrivacyProtocol,
16+
SNMPv3Conf,
1817
)
18+
from kentik_api.public.types import ID
1919
from kentik_api.utils import get_credentials
2020

2121
logging.basicConfig(level=logging.INFO)

kentik_api_library/examples/dimensions_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import logging
77
import random
88
import string
9-
from kentik_api import KentikAPI, CustomDimension, Populator
9+
10+
from kentik_api import CustomDimension, KentikAPI, Populator
1011
from kentik_api.utils import get_credentials
1112

1213
logging.basicConfig(level=logging.INFO)

kentik_api_library/examples/error_handling_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44

5-
from kentik_api import KentikAPI, AuthError, NotFoundError, IncompleteObjectError, Device, RateLimitExceededError
5+
from kentik_api import AuthError, Device, IncompleteObjectError, KentikAPI, NotFoundError, RateLimitExceededError
66
from kentik_api.public.types import ID
77
from kentik_api.utils import get_credentials
88

kentik_api_library/examples/labels_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"""
55

66
import logging
7-
from kentik_api import KentikAPI, DeviceLabel
7+
8+
from kentik_api import DeviceLabel, KentikAPI
89
from kentik_api.public.types import ID
910
from kentik_api.utils import get_credentials
1011

kentik_api_library/examples/my_kentik_portal_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import logging
7+
78
from kentik_api import KentikAPI
89
from kentik_api.utils import get_credentials
910

kentik_api_library/examples/plans_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import logging
7+
78
from kentik_api import KentikAPI
89
from kentik_api.utils import get_credentials
910

kentik_api_library/examples/queries_example.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55

66
import logging
77
from io import BytesIO
8+
89
from PIL import Image # type: ignore
10+
911
from kentik_api import (
10-
KentikAPI,
11-
QuerySQL,
12-
QueryObject,
13-
QueryArrayItem,
14-
Query,
1512
Aggregate,
1613
AggregateFunctionType,
17-
FastDataType,
18-
MetricType,
14+
ChartViewType,
1915
DimensionType,
16+
FastDataType,
2017
ImageType,
21-
ChartViewType,
18+
KentikAPI,
19+
MetricType,
20+
Query,
21+
QueryArrayItem,
22+
QueryObject,
23+
QuerySQL,
2224
)
2325
from kentik_api.utils import get_credentials
2426

kentik_api_library/examples/saved_filters_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"""
55

66
import logging
7-
from kentik_api import KentikAPI, SavedFilter, Filters, FilterGroups, Filter
7+
8+
from kentik_api import Filter, FilterGroups, Filters, KentikAPI, SavedFilter
89
from kentik_api.utils import get_credentials
910

1011
logging.basicConfig(level=logging.INFO)

kentik_api_library/examples/sites_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import logging
7+
78
from kentik_api import KentikAPI, Site
89
from kentik_api.utils import get_credentials
910

kentik_api_library/examples/tags_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import logging
7+
78
from kentik_api import KentikAPI, Tag
89
from kentik_api.utils import get_credentials
910

kentik_api_library/examples/users_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import logging
7+
78
from kentik_api import KentikAPI, User
89
from kentik_api.utils import get_credentials
910

kentik_api_library/kentik_api/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from requests.packages.urllib3.util.retry import Retry
2+
13
from .kentik_api import KentikAPI
24
from .public import *
3-
from requests.packages.urllib3.util.retry import Retry

kentik_api_library/kentik_api/analytics/mapped_query.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,7 @@
33
import re
44
from collections import defaultdict
55
from dataclasses import dataclass
6-
from typing import (
7-
Any,
8-
Callable,
9-
Dict,
10-
Generator,
11-
List,
12-
Optional,
13-
Tuple,
14-
Type,
15-
TypeVar,
16-
Union,
17-
)
6+
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Type, TypeVar, Union
187

198
import yaml
209
from pandas import DataFrame, to_datetime

kentik_api_library/kentik_api/api_calls/active_alerts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, payload_type
32
from kentik_api.api_calls.api_call import APICall
3+
from kentik_api.api_calls.api_call_decorators import get, payload_type
44

55

66
@get

kentik_api_library/kentik_api/api_calls/alerts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Optional
22

3-
from kentik_api.api_calls.api_call_decorators import get, post, payload_type
43
from kentik_api.api_calls.api_call import APICall
4+
from kentik_api.api_calls.api_call_decorators import get, payload_type, post
55

66

77
@post

kentik_api_library/kentik_api/api_calls/batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from kentik_api.api_calls.api_call_decorators import get, post, payload_type
21
from kentik_api.api_calls.api_call import APICall
2+
from kentik_api.api_calls.api_call_decorators import get, payload_type, post
33

44

55
@post

kentik_api_library/kentik_api/api_calls/custom_applications.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, post, put, delete, payload_type
32
from kentik_api.api_calls.api_call import APICall, ResourceID
3+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post, put
44

55

66
@get

kentik_api_library/kentik_api/api_calls/custom_dimensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, post, put, delete, payload_type
32
from kentik_api.api_calls.api_call import APICall, ResourceID
3+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post, put
44

55

66
@get

kentik_api_library/kentik_api/api_calls/device_labels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, post, put, delete, payload_type
32
from kentik_api.api_calls.api_call import APICall, ResourceID
3+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post, put
44

55

66
@get

kentik_api_library/kentik_api/api_calls/devices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, post, put, delete, payload_type
32
from kentik_api.api_calls.api_call import APICall, ResourceID
3+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post, put
44

55

66
@get

kentik_api_library/kentik_api/api_calls/my_kentik_portal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, post, delete, payload_type
32
from kentik_api.api_calls.api_call import APICall, ResourceID
3+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post
44

55

66
@get

kentik_api_library/kentik_api/api_calls/plans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get
32
from kentik_api.api_calls.api_call import APICall
3+
from kentik_api.api_calls.api_call_decorators import get
44

55

66
@get

kentik_api_library/kentik_api/api_calls/query_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import post, payload_type
32
from kentik_api.api_calls.api_call import APICall
3+
from kentik_api.api_calls.api_call_decorators import payload_type, post
44

55

66
@post

kentik_api_library/kentik_api/api_calls/saved_filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from kentik_api.api_calls.api_call_decorators import get, post, put, delete, payload_type
21
from kentik_api.api_calls.api_call import APICall, ResourceID
2+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post, put
33

44

55
@get

kentik_api_library/kentik_api/api_calls/sites.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, post, put, delete, payload_type
32
from kentik_api.api_calls.api_call import APICall, ResourceID
3+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post, put
44

55

66
@get

kentik_api_library/kentik_api/api_calls/tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, post, put, delete, payload_type
32
from kentik_api.api_calls.api_call import APICall, ResourceID
3+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post, put
44

55

66
@get

kentik_api_library/kentik_api/api_calls/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Local application imports
2-
from kentik_api.api_calls.api_call_decorators import get, post, put, delete, payload_type
32
from kentik_api.api_calls.api_call import APICall, ResourceID
3+
from kentik_api.api_calls.api_call_decorators import delete, get, payload_type, post, put
44

55

66
@get

kentik_api_library/kentik_api/api_connection/api_connector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Standard library imports
22
import logging
33
from http import HTTPStatus
4-
from typing import Union, Tuple, Optional, Dict, Any
4+
from typing import Any, Dict, Optional, Tuple, Union
55

66
# Third party imports
7-
from requests import Timeout, RequestException, Response
7+
from requests import RequestException, Response, Timeout
88

99
# Local application imports
1010
from kentik_api.api_calls.api_call import APICall, APICallMethods
@@ -20,7 +20,8 @@
2020
TimedOutError,
2121
UnavailabilityError,
2222
)
23-
from .retryable_session import RetryableSession, Retry
23+
24+
from .retryable_session import Retry, RetryableSession
2425

2526
PROTOCOL_HTTP = "HTTP"
2627

kentik_api_library/kentik_api/api_connection/api_connector_protocol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Optional, Dict, Any
1+
from typing import Any, Dict, Optional
2+
23
from typing_extensions import Protocol
34

45
from kentik_api.api_calls.api_call import APICall

kentik_api_library/kentik_api/api_connection/retryable_session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import logging
2+
from typing import Optional
3+
24
from requests import Session
35
from requests.adapters import HTTPAdapter
46
from requests.packages.urllib3.util.retry import Retry
5-
from typing import Optional
67

78
log = logging.getLogger(__name__)
89

0 commit comments

Comments
 (0)