Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pyproject.toml for tooling, add isort management of imports #975

Merged
merged 3 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
e116d26eeca0891c31b689e43db5bb60b62f73f6
# Commit that fixed a bunch of uneeded '...' '...' string joins from ^
fa4225b625654c51c7b0be6efcfd6a1109768a72
# Commit that added in isort formatting support
6be0a8133a4fd9e12e6ac3affbdd69555b6c2503
1 change: 1 addition & 0 deletions octodns/cmds/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from logging.config import dictConfig
from logging.handlers import SysLogHandler
from sys import stderr, stdout

from yaml import safe_load

from octodns import __VERSION__
Expand Down
2 changes: 1 addition & 1 deletion octodns/cmds/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Octo-DNS Comparator
'''

from pprint import pprint
import sys
from pprint import pprint

from octodns.cmds.args import ArgumentParser
from octodns.manager import Manager
Expand Down
7 changes: 4 additions & 3 deletions octodns/cmds/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
Octo-DNS Reporter
'''

import re
from concurrent.futures import ThreadPoolExecutor
from dns.exception import Timeout
from dns.resolver import NXDOMAIN, NoAnswer, NoNameservers, Resolver, query
from logging import getLogger
from sys import stdout
import re

from dns.exception import Timeout
from dns.resolver import NXDOMAIN, NoAnswer, NoNameservers, Resolver, query

from octodns.cmds.args import ArgumentParser
from octodns.manager import Manager
Expand Down
4 changes: 3 additions & 1 deletion octodns/idna.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

from collections.abc import MutableMapping

from idna import IDNAError as _IDNAError, decode as _decode, encode as _encode
from idna import IDNAError as _IDNAError
from idna import decode as _decode
from idna import encode as _encode

# Providers will need to to make calls to these at the appropriate points,
# generally right before they pass names off to api calls. For an example of
Expand Down
9 changes: 3 additions & 6 deletions octodns/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
from .yaml import safe_load
from .zone import Zone


# TODO: this can go away once we no longer support python 3.7
try:
from importlib.metadata import (
PackageNotFoundError,
version as module_version,
)
try: # pragma: no cover
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as module_version
except ModuleNotFoundError: # pragma: no cover

class PackageNotFoundError(Exception):
Expand Down
1 change: 0 additions & 1 deletion octodns/processor/ownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from ..provider.plan import Plan
from ..record import Record

from .base import BaseProcessor


Expand Down
2 changes: 1 addition & 1 deletion octodns/provider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from ..source.base import BaseSource
from ..zone import Zone
from .plan import Plan
from . import SupportsException
from .plan import Plan


class BaseProvider(BaseSource):
Expand Down
3 changes: 1 addition & 2 deletions octodns/provider/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
#
#

from io import StringIO
from logging import DEBUG, ERROR, INFO, WARN, getLogger
from sys import stdout

from io import StringIO


class UnsafePlan(Exception):
pass
Expand Down
6 changes: 3 additions & 3 deletions octodns/provider/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#
#

import logging
from collections import defaultdict
from os import listdir, makedirs
from os.path import isdir, isfile, join
import logging

from ..record import Record
from ..yaml import safe_load, safe_dump
from .base import BaseProvider
from ..yaml import safe_dump, safe_load
from . import ProviderException
from .base import BaseProvider


class YamlProvider(BaseProvider):
Expand Down
6 changes: 3 additions & 3 deletions octodns/record/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
from .loc import LocRecord, LocValue
from .mx import MxRecord, MxValue
from .naptr import NaptrRecord, NaptrValue
from .ns import NsValue, NsRecord
from .ptr import PtrValue, PtrRecord
from .ns import NsRecord, NsValue
from .ptr import PtrRecord, PtrValue
from .rr import Rr, RrParseError
from .spf import SpfRecord
from .srv import SrvRecord, SrvValue
from .sshfp import SshfpRecord, SshfpValue
from .tlsa import TlsaRecord, TlsaValue
from .txt import TxtValue, TxtRecord
from .txt import TxtRecord, TxtValue
from .urlfwd import UrlfwdRecord, UrlfwdValue

# quell warnings
Expand Down
3 changes: 2 additions & 1 deletion octodns/record/chunked.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#
#

from .base import ValuesMixin
import re

from .base import ValuesMixin


class _ChunkedValuesMixin(ValuesMixin):
CHUNK_SIZE = 255
Expand Down
2 changes: 1 addition & 1 deletion octodns/record/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
#

from logging import getLogger
import re
from logging import getLogger

from .change import Update
from .geo import GeoCodes
Expand Down
2 changes: 1 addition & 1 deletion octodns/record/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
#

from logging import getLogger
import re
from logging import getLogger

from ..equality import EqualityTupleMixin
from .base import ValuesMixin
Expand Down
3 changes: 2 additions & 1 deletion octodns/record/srv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#
#

from fqdn import FQDN
import re

from fqdn import FQDN

from ..equality import EqualityTupleMixin
from ..idna import idna_encode
from .base import Record, ValuesMixin
Expand Down
6 changes: 3 additions & 3 deletions octodns/source/tinydns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#
#

import logging
import re
import textwrap
from collections import defaultdict
from ipaddress import ip_address
from os import listdir
from os.path import join
import logging
import re
import textwrap

from ..record import Record
from ..zone import DuplicateRecordException, SubzoneRecordException
Expand Down
5 changes: 2 additions & 3 deletions octodns/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
#

from natsort import natsort_keygen
from yaml import SafeDumper, SafeLoader, load, dump
from yaml.representer import SafeRepresenter
from yaml import SafeDumper, SafeLoader, dump, load
from yaml.constructor import ConstructorError

from yaml.representer import SafeRepresenter

_natsort_key = natsort_keygen()

Expand Down
2 changes: 1 addition & 1 deletion octodns/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#
#

import re
from collections import defaultdict
from logging import getLogger
import re

from .idna import idna_decode, idna_encode
from .record import Create, Delete
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tool.black]
line-length=80
skip-string-normalization=true
skip-magic-trailing-comma=true

[tool.isort]
profile = "black"
known_first_party="octodns"
line_length=80

[tool.pytest.ini_options]
pythonpath = "."
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ docutils==0.19
exceptiongroup==1.0.0
importlib-metadata==5.0.0
iniconfig==1.1.1
isort==5.11.4
jaraco.classes==3.2.3
keyring==23.9.3
more-itertools==9.0.0
Expand Down
2 changes: 0 additions & 2 deletions script/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ grep -r -I --line-number "# pragma: +no.*cover" $SOURCE_DIR && {
exit 1
}

export PYTHONPATH=.:$PYTHONPATH

pytest \
--disable-network \
--cov-reset \
Expand Down
3 changes: 2 additions & 1 deletion script/format
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ SOURCES=$(find *.py octodns tests -name "*.py")

. env/bin/activate

black --line-length=80 --skip-string-normalization --skip-magic-trailing-comma "$@" $SOURCES
isort "$@" $SOURCES
black "$@" $SOURCES
2 changes: 0 additions & 2 deletions script/test
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ export ARM_CLIENT_SECRET=
export ARM_TENANT_ID=
export ARM_SUBSCRIPTION_ID=

export PYTHONPATH=.:$PYTHONPATH

pytest --disable-network "$@"
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from os import environ
from os.path import dirname, join
from subprocess import CalledProcessError, check_output

import octodns

try:
Expand Down Expand Up @@ -73,6 +74,7 @@ def version():
+ (
'black>=22.3.0',
'build>=0.7.0',
'isort>=5.11.4',
'pycountry>=19.8.18',
'pycountry-convert>=0.7.2',
'pyflakes>=2.2.0',
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#
#

from logging import getLogger
from shutil import rmtree
from tempfile import mkdtemp
from logging import getLogger

from octodns.processor.base import BaseProcessor
from octodns.provider.base import BaseProvider
Expand Down
25 changes: 12 additions & 13 deletions tests/test_octodns_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,31 @@

from os import environ
from os.path import dirname, isfile, join
from unittest import TestCase
from unittest.mock import MagicMock, patch

from helpers import (
DynamicProvider,
GeoProvider,
NoSshFpProvider,
PlannableProvider,
SimpleProvider,
TemporaryDirectory,
)

from octodns import __VERSION__
from octodns.idna import IdnaDict, idna_encode
from octodns.manager import (
_AggregateTarget,
MainThreadExecutor,
Manager,
ManagerException,
_AggregateTarget,
)
from octodns.processor.base import BaseProcessor
from octodns.record import Create, Delete, Record
from octodns.yaml import safe_load
from octodns.zone import Zone

from unittest import TestCase
from unittest.mock import MagicMock, patch

from helpers import (
DynamicProvider,
GeoProvider,
NoSshFpProvider,
PlannableProvider,
SimpleProvider,
TemporaryDirectory,
)

config_dir = join(dirname(__file__), 'config')


Expand Down
5 changes: 2 additions & 3 deletions tests/test_octodns_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from logging import getLogger
from unittest import TestCase

from helpers import SimpleProvider

from octodns.provider.plan import (
Plan,
PlanHtml,
Expand All @@ -17,9 +19,6 @@
from octodns.record import Create, Delete, Record, Update
from octodns.zone import Zone

from helpers import SimpleProvider


simple = SimpleProvider()
zone = Zone('unit.tests.', [])
existing = Record.new(
Expand Down
5 changes: 2 additions & 3 deletions tests/test_octodns_processor_ownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

from unittest import TestCase

from helpers import PlannableProvider

from octodns.processor.ownership import OwnershipProcessor
from octodns.record import Delete, Record
from octodns.zone import Zone

from helpers import PlannableProvider


zone = Zone('unit.tests.', [])
records = {}
for record in [
Expand Down
8 changes: 4 additions & 4 deletions tests/test_octodns_provider_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
from os import makedirs
from os.path import basename, dirname, isdir, isfile, join
from unittest import TestCase

from helpers import TemporaryDirectory
from yaml import safe_load
from yaml.constructor import ConstructorError

from octodns.idna import idna_encode
from octodns.record import NsValue, Create, Record, ValuesMixin
from octodns.provider import ProviderException
from octodns.provider.base import Plan
from octodns.provider.yaml import (
_list_all_yaml_files,
SplitYamlProvider,
YamlProvider,
_list_all_yaml_files,
)
from octodns.record import Create, NsValue, Record, ValuesMixin
from octodns.zone import SubzoneRecordException, Zone

from helpers import TemporaryDirectory


class TestYamlProvider(TestCase):
def test_provider(self):
Expand Down