Skip to content

Commit

Permalink
Merge pull request #46 from octodns/isort
Browse files Browse the repository at this point in the history
Use pyproject.toml for tooling, add isort management of imports
  • Loading branch information
ross committed Feb 4, 2023
2 parents 093c9d6 + 97fd7cd commit 0f04cba
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 64 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Commit that added in black formatting support
639eb83171fd441648a44de85b30eeb7b96e9ab0
# Commit for isort formatting changes
1f1eb99aaccf6a3314bf2eadae32402978c3c318
1 change: 0 additions & 1 deletion octodns_route53/processor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class AwsAcmMangingProcessor(BaseProcessor):

log = getLogger('AwsAcmMangingProcessor')

def _ignore_awsacm_cnames(self, zone):
Expand Down
16 changes: 7 additions & 9 deletions octodns_route53/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
#
#

import hashlib
import logging
import re
from collections import defaultdict
from ipaddress import AddressValueError, ip_address
from pycountry_convert import country_alpha2_to_continent_code
from uuid import uuid4
import logging
import re
import hashlib

from pycountry_convert import country_alpha2_to_continent_code

from octodns.equality import EqualityTupleMixin
from octodns.record import Create, Record, Update
from octodns.record.geo import GeoCodes
from octodns.provider import ProviderException
from octodns.provider.base import BaseProvider
from octodns.record import Create, Record, Update
from octodns.record.geo import GeoCodes

from .auth import _AuthMixin
from .record import Route53AliasRecord
Expand Down Expand Up @@ -83,7 +84,6 @@ def _new_dynamic(cls, provider, record, hosted_zone_id, creating):

# Pools
for pool_name, pool in record.dynamic.pools.items():

# Create the primary, this will be the rrset that geo targeted
# rrsets will point to when they want to use a pool of values. It's
# a primary and observes target health so if all the values for
Expand Down Expand Up @@ -222,7 +222,6 @@ def values(self):
return self._values

def mod(self, action, existing_rrsets):

return {
'Action': action,
'ResourceRecordSet': {
Expand Down Expand Up @@ -518,7 +517,6 @@ def identifer(self):
return f'{self.pool_name}-{self.index:03d}'

def mod(self, action, existing_rrsets):

if action == 'DELETE':
# When deleting records try and find the original rrset so that
# we're 100% sure to have the complete & accurate data (this mostly
Expand Down
2 changes: 1 addition & 1 deletion octodns_route53/record.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from octodns.record import Record, ValuesMixin
from octodns.equality import EqualityTupleMixin
from octodns.record import Record, ValuesMixin


class _Route53AliasValue(EqualityTupleMixin, dict):
Expand Down
2 changes: 1 addition & 1 deletion octodns_route53/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from logging import getLogger

from octodns.idna import idna_encode
from octodns.source.base import BaseSource
from octodns.record import Record
from octodns.source.base import BaseSource

from .auth import _AuthMixin

Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.black]
line-length=80
skip-string-normalization=true
skip-magic-trailing-comma=true

[tool.isort]
profile = "black"
known_first_party="octodns_route53"
known_octodns="octodns"
line_length=80
sections="FUTURE,STDLIB,THIRDPARTY,OCTODNS,FIRSTPARTY,LOCALFOLDER"

[tool.pytest.ini_options]
pythonpath = "."
42 changes: 22 additions & 20 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
# DO NOT EDIT THIS FILE DIRECTLY - use ./script/update-requirements to update
Pygments==2.13.0
black==22.10.0
bleach==5.0.1
build==0.8.0
Pygments==2.14.0
black==23.1.0
bleach==6.0.0
build==0.10.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==2.1.1
charset-normalizer==3.0.1
click==8.1.3
cmarkgfm==0.8.0
commonmark==0.9.1
cmarkgfm==2022.10.27
docutils==0.19
importlib-metadata==5.0.0
importlib-metadata==6.0.0
isort==5.11.5
jaraco.classes==3.2.3
keyring==23.9.3
keyring==23.13.1
markdown-it-py==2.1.0
mdurl==0.1.2
more-itertools==9.0.0
mypy-extensions==0.4.3
pathspec==0.10.1
pep517==0.13.0
pkginfo==1.8.3
platformdirs==2.5.2
mypy-extensions==1.0.0
pathspec==0.11.0
pkginfo==1.9.6
platformdirs==2.6.2
pycparser==2.21
pyflakes==2.5.0
pyflakes==3.0.1
pyproject_hooks==1.0.0
pytest-network==0.0.1
readme-renderer==37.2
readme-renderer==37.3
requests-toolbelt==0.10.1
requests==2.28.1
requests==2.28.2
rfc3986==2.0.0
rich==12.6.0
twine==4.0.1
rich==13.3.1
twine==4.0.2
webencodings==0.5.1
zipp==3.10.0
zipp==3.12.0
21 changes: 10 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
# DO NOT EDIT THIS FILE DIRECTLY - use ./script/update-requirements to update
PyYAML==6.0
attrs==22.1.0
boto3==1.25.1
botocore==1.28.1
coverage==6.5.0
dnspython==2.2.1
exceptiongroup==1.0.0rc9
attrs==22.2.0
boto3==1.26.64
botocore==1.29.64
coverage==7.1.0
dnspython==2.3.0
exceptiongroup==1.1.0
fqdn==1.5.1
idna==3.4
iniconfig==1.1.1
iniconfig==2.0.0
jmespath==1.0.1
natsort==8.2.0
octodns==0.9.21
packaging==21.3
packaging==23.0
pluggy==1.0.0
pprintpp==0.4.0
pycountry-convert==0.7.2
pycountry==22.3.5
pyparsing==3.0.9
pytest-cov==4.0.0
pytest-mock==3.10.0
pytest==7.2.0
pytest==7.2.1
python-dateutil==2.8.2
repoze.lru==0.7
s3transfer==0.6.0
six==1.16.0
tomli==2.0.1
urllib3==1.26.12
urllib3==1.26.14
2 changes: 0 additions & 2 deletions script/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ grep -r -I --line-number "# pragma: +no.*cover" $SOURCE_DIR && {
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=

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 @@ -17,6 +17,4 @@ fi
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=

export PYTHONPATH=.:$PYTHONPATH

pytest --disable-network "$@"
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from os import environ
from setuptools import find_packages, setup
from subprocess import CalledProcessError, check_output

from setuptools import find_packages, setup


def descriptions():
with open('README.md') as fh:
Expand Down Expand Up @@ -43,6 +44,8 @@ def version():
+ (
'black>=22.3.0',
'build>=0.7.0',
# >=5.12.0 does not support python 3.7, we still do
'isort==5.11.5',
'pyflakes>=2.2.0',
'readme_renderer[md]>=26.0',
'twine>=3.4.2',
Expand Down
20 changes: 7 additions & 13 deletions tests/test_octodns_provider_route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
#
#

from botocore.exceptions import ClientError
from botocore.stub import ANY, Stubber
from unittest import TestCase
from unittest.mock import patch

from botocore.exceptions import ClientError
from botocore.stub import ANY, Stubber

from octodns.record import Create, Delete, Record, Update
from octodns.zone import Zone

from octodns_route53 import Route53Provider, Route53ProviderException
from octodns_route53.record import _Route53AliasValue, Route53AliasRecord
from octodns_route53.processor import AwsAcmMangingProcessor
from octodns_route53.provider import (
_healthcheck_ref_prefix,
_mod_keyer,
_octal_replace,
_Route53Alias,
_Route53DynamicValue,
_Route53GeoDefault,
_Route53GeoRecord,
_Route53Record,
_mod_keyer,
_octal_replace,
_healthcheck_ref_prefix,
)
from octodns_route53.record import Route53AliasRecord, _Route53AliasValue


class GeoProvider(object):
Expand Down Expand Up @@ -3091,7 +3092,6 @@ def test_extra_change_dynamic_has_health_check_cname(self):
stubber.assert_no_pending_responses()

def _get_test_plan(self, max_changes):

provider = Route53Provider('test', 'abc', '123', max_changes)

# Use the stubber
Expand Down Expand Up @@ -3171,7 +3171,6 @@ def _get_test_plan(self, max_changes):
@patch('octodns_route53.Route53Provider._load_records')
@patch('octodns_route53.Route53Provider._really_apply')
def test_apply_1(self, really_apply_mock, _):

# 18 RRs with max of 19 should only get applied in one call
provider, plan = self._get_test_plan(19)
provider.apply(plan)
Expand All @@ -3180,7 +3179,6 @@ def test_apply_1(self, really_apply_mock, _):
@patch('octodns_route53.Route53Provider._load_records')
@patch('octodns_route53.Route53Provider._really_apply')
def test_apply_2(self, really_apply_mock, _):

# 18 RRs with max of 17 should only get applied in two calls
provider, plan = self._get_test_plan(18)
provider.apply(plan)
Expand All @@ -3189,7 +3187,6 @@ def test_apply_2(self, really_apply_mock, _):
@patch('octodns_route53.Route53Provider._load_records')
@patch('octodns_route53.Route53Provider._really_apply')
def test_apply_3(self, really_apply_mock, _):

# with a max of seven modifications, three calls
provider, plan = self._get_test_plan(7)
provider.apply(plan)
Expand All @@ -3198,7 +3195,6 @@ def test_apply_3(self, really_apply_mock, _):
@patch('octodns_route53.Route53Provider._load_records')
@patch('octodns_route53.Route53Provider._really_apply')
def test_apply_4(self, really_apply_mock, _):

# with a max of 11 modifications, two calls
provider, plan = self._get_test_plan(11)
provider.apply(plan)
Expand All @@ -3207,7 +3203,6 @@ def test_apply_4(self, really_apply_mock, _):
@patch('octodns_route53.Route53Provider._load_records')
@patch('octodns_route53.Route53Provider._really_apply')
def test_apply_bad(self, really_apply_mock, _):

# with a max of 1 modifications, fail
provider, plan = self._get_test_plan(1)
with self.assertRaises(Exception) as ctx:
Expand Down Expand Up @@ -3836,7 +3831,6 @@ def test_new_dynamic(self):

class TestModKeyer(TestCase):
def test_mod_keyer(self):

# First "column" is the action priority for C/R/U

# Deletes come first
Expand Down
3 changes: 2 additions & 1 deletion tests/test_octodns_source_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#
#

from botocore.stub import Stubber
from unittest import TestCase

from botocore.stub import Stubber

from octodns.zone import DuplicateRecordException, Zone

from octodns_route53 import Ec2Source
Expand Down
3 changes: 2 additions & 1 deletion tests/test_octodns_source_elb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#
#

from botocore.stub import Stubber
from unittest import TestCase

from botocore.stub import Stubber

from octodns.zone import Zone

from octodns_route53 import ElbSource
Expand Down

0 comments on commit 0f04cba

Please sign in to comment.