add isort to project

This commit is contained in:
Istvan Ruzman
2020-08-17 08:03:57 +02:00
parent 10766b842c
commit e2c25d076d
11 changed files with 42 additions and 41 deletions

View File

@@ -3,8 +3,8 @@ python:
- "3.7" - "3.7"
- "3.8" - "3.8"
# command to install dependencies # command to install dependencies
install: "pip install pytest pytest-black pytest-cov pytest-mypy pytest-pylint pytest-flake8 coveralls" install: "pip install pytest pytest-black pytest-cov pylint-isort pytest-mypy pytest-pylint pytest-flake8 coveralls"
# command to run tests # command to run tests
script: pytest --black --pylint --pylint-jobs=4 --mypy --cov=pyrad3 --flake8 script: pytest --black --isort --pylint --pylint-jobs=4 --mypy --flake8 --cov=pyrad3
after_success: after_success:
- coveralls - coveralls

View File

@@ -7,7 +7,6 @@ build-backend = "poetry.core.masonry.api"
name = "pyrad3" name = "pyrad3"
version = "0.1.0" version = "0.1.0"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
requires-python = ">=3.7"
readme = "README.md" readme = "README.md"
description = "RADIUS tools" description = "RADIUS tools"
keywords = ["AAA", "authentication", "authorization", "accounting", "RADIUS"] keywords = ["AAA", "authentication", "authorization", "accounting", "RADIUS"]
@@ -35,10 +34,14 @@ include = [
[tool.poetry.urls] [tool.poetry.urls]
repository = "https://github.com/pyradius/pyrad3" repository = "https://github.com/pyradius/pyrad3"
[tool.poetry.dependencies]
python = "^3.7"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
black = "^19.3.10b0"
pytest = "^5.4" pytest = "^5.4"
pytest-black = "^0.30" pytest-black = "^0.3.10"
pytest-cov = "^2.10" pytest-cov = "^2.10"
pytest-mypy = "^0.6" pytest-mypy = "^0.6"
pytest-pylint = "^0.17" pytest-pylint = "^0.17"
@@ -49,5 +52,13 @@ line-length = 80
include = '\.py' include = '\.py'
[tool.isort]
multi_line_output = 3
include_trailing_comma = true
use_parentheses = true
line_length = 88
combine_as_imports = true
[tool.pylint.messages_control] [tool.pylint.messages_control]
disable = "bad-continuation" disable = "bad-continuation"

View File

@@ -8,10 +8,12 @@ pkgs.mkShell {
pkgs.python3 pkgs.python3
pkgs.python3Packages.coveralls pkgs.python3Packages.coveralls
pkgs.python3Packages.black pkgs.python3Packages.black
pkgs.python3Packages.poetry
pkgs.python3Packages.pytest pkgs.python3Packages.pytest
pkgs.python3Packages.pytest-black pkgs.python3Packages.pytest-black
pkgs.python3Packages.pytestcov pkgs.python3Packages.pytestcov
pkgs.python3Packages.pytest-flake8 pkgs.python3Packages.pytest-flake8
pkgs.python3Packages.pytest-isort
pkgs.python3Packages.pytest-mypy pkgs.python3Packages.pytest-mypy
pkgs.python3Packages.pytest-pylint pkgs.python3Packages.pytest-pylint
]; ];

View File

@@ -3,16 +3,15 @@
"""Implementation of a simple but extensible RADIUS Client""" """Implementation of a simple but extensible RADIUS Client"""
from typing import cast, Optional, Union
from ipaddress import IPv4Address, IPv6Address
import select import select
import socket import socket
import time import time
from ipaddress import IPv4Address, IPv6Address
from typing import Optional, Union, cast
import pyrad3.packet as P import pyrad3.packet as P
from pyrad3.dictionary import Dictionary
from pyrad3 import host from pyrad3 import host
from pyrad3.dictionary import Dictionary
SUPPORTED_SEND_TYPES = [ SUPPORTED_SEND_TYPES = [
P.Code.AccessRequest, P.Code.AccessRequest,

View File

@@ -6,21 +6,11 @@
Classes and Types to parse and represent a RADIUS dictionary. Classes and Types to parse and represent a RADIUS dictionary.
""" """
from enum import IntEnum, Enum, auto
from dataclasses import dataclass
from os.path import dirname, isabs, join, normpath
from typing import (
Dict,
Generator,
IO,
List,
Optional,
Sequence,
Tuple,
Union,
)
import logging import logging
from dataclasses import dataclass
from enum import Enum, IntEnum, auto
from os.path import dirname, isabs, join, normpath
from typing import IO, Dict, Generator, List, Optional, Sequence, Tuple, Union
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@@ -3,8 +3,8 @@
"""Interface Class for RADIUS Clients and Servers""" """Interface Class for RADIUS Clients and Servers"""
from pyrad3.dictionary import Dictionary
from pyrad3 import packet from pyrad3 import packet
from pyrad3.dictionary import Dictionary
class Host: # pylint: disable=too-many-arguments,too-many-instance-attributes class Host: # pylint: disable=too-many-arguments,too-many-instance-attributes

View File

@@ -3,23 +3,22 @@
"""Class for RADIUS Packet""" """Class for RADIUS Packet"""
import hashlib
import hmac
from collections import OrderedDict from collections import OrderedDict
from secrets import token_bytes from secrets import token_bytes
from typing import Any, Dict, Optional, Sequence, Tuple, Union from typing import Any, Dict, Optional, Sequence, Tuple, Union
import hashlib
import hmac
from pyrad3.host import Host
from pyrad3.code import Code from pyrad3.code import Code
from pyrad3.host import Host
from pyrad3.utils import ( from pyrad3.utils import (
PacketError,
Attribute, Attribute,
parse_header, PacketError,
parse_attributes,
calculate_authenticator, calculate_authenticator,
validate_pap_password, parse_attributes,
parse_header,
validate_chap_password, validate_chap_password,
validate_pap_password,
) )
HMAC = hmac.new HMAC = hmac.new

View File

@@ -3,17 +3,16 @@
"""Collections of functions to en- and decode RADIUS Attributes""" """Collections of functions to en- and decode RADIUS Attributes"""
from typing import Optional, Union import struct
from ipaddress import ( from ipaddress import (
IPv4Address, IPv4Address,
IPv4Network, IPv4Network,
IPv6Address, IPv6Address,
IPv6Network, IPv6Network,
ip_network,
ip_address, ip_address,
ip_network,
) )
from typing import Optional, Union
import struct
def encode_string(string: str) -> bytes: def encode_string(string: str) -> bytes:

View File

@@ -3,15 +3,14 @@
"""Collection of functions to deal with RADIUS packet en- and decoding.""" """Collection of functions to deal with RADIUS packet en- and decoding."""
from collections import namedtuple
from typing import List, Optional, Tuple, Union
import hashlib import hashlib
import secrets import secrets
import struct import struct
from collections import namedtuple
from typing import List, Optional, Tuple, Union
from pyrad3.dictionary import Dictionary
from pyrad3.code import Code from pyrad3.code import Code
from pyrad3.dictionary import Dictionary
RANDOM_GENERATOR = secrets.SystemRandom() RANDOM_GENERATOR = secrets.SystemRandom()
MD5 = hashlib.md5 MD5 = hashlib.md5

View File

@@ -4,6 +4,7 @@
from io import StringIO from io import StringIO
import pytest import pytest
from pyrad3.dictionary import Dictionary, ParseError from pyrad3.dictionary import Dictionary, ParseError

View File

@@ -2,11 +2,12 @@
# SPDX-License-Identifier: MIT OR Apache-2.0 # SPDX-License-Identifier: MIT OR Apache-2.0
import struct import struct
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
from ipaddress import IPv4Address, IPv6Address, IPv4Network, IPv6Network
from pyrad3 import dictionary, utils
import pytest import pytest
from pyrad3 import dictionary, utils
# @pytest.mark.parametrize("header", [ # @pytest.mark.parametrize("header", [
# b""]) # b""])
# def test_valid_header(header): # def test_valid_header(header):