Skip to content

Commit

Permalink
Drop Python 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraichen committed May 1, 2020
1 parent e3b1b00 commit 2ec449d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python: [2.7, 3.6, 3.7]
salt: [2016.11.10, 2017.7.8, 2018.3.4, 2019.2.0, '3000.0']
exclude:
- {python: 3.6, salt: 2016.11.10}
- {python: 3.6, salt: 2017.7.8}
- {python: 3.7, salt: 2016.11.10}
- {python: 3.7, salt: 2017.7.8}
python: [3.6, 3.7]
salt: [2018.3.4, 2019.2.0, '3000.0']

steps:
- uses: actions/checkout@v1
Expand Down
17 changes: 8 additions & 9 deletions salt_tower/pillar/tower.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from glob import glob

import salt.ext.six as six
import salt.loader
import salt.minion
import salt.template
Expand Down Expand Up @@ -89,15 +88,15 @@ def merge(self, *args, **kwargs):

def format(self, obj, *args, **kwargs):
if isinstance(obj, collections.Mapping):
return {k: self.format(v, *args, **kwargs) for k, v in six.iteritems(obj)}
return {k: self.format(v, *args, **kwargs) for k, v in obj.items()}

if isinstance(obj, list):
return [self.format(i, *args, **kwargs) for i in obj]

if isinstance(obj, six.string_types):
if six.PY3 and isinstance(obj, bytes):
return obj
if isinstance(obj, bytes):
return obj

if isinstance(obj, str):
try:
return self._formatter.format(obj, *args, **kwargs)
except ValueError:
Expand All @@ -111,11 +110,11 @@ def run(self, top):
base = os.path.dirname(top)

for item in self._load_top(top):
if isinstance(item, six.string_types):
if isinstance(item, str):
self._load_item(base, item)

elif isinstance(item, collections.Mapping):
for tgt, items in six.iteritems(item):
for tgt, items in item.items():
if not self._match_minion(tgt):
continue

Expand Down Expand Up @@ -156,7 +155,7 @@ def _load_item(self, base, item):
if isinstance(item, collections.Mapping):
self.update(item, merge=True)

elif isinstance(item, six.string_types):
elif isinstance(item, str):
self.load(item, base)

def lookup(self, item, base=None, cwd=None):
Expand Down Expand Up @@ -297,7 +296,7 @@ def _merge_dict(tgt, obj):
raise TypeError(
'Cannot merge non-dict type, but is {}'.format(type(obj)))

for key, val in six.iteritems(obj):
for key, val in obj.items():
if key in tgt:
if isinstance(tgt[key], collections.Mapping) \
and isinstance(val, collections.Mapping):
Expand Down
3 changes: 1 addition & 2 deletions salt_tower/renderers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@
{'path': {'to': {'blob': 'A short text message'}}}
'''
from salt.ext.six import string_types


def render(blob, _saltenv, _sls, argline=None, key=None, **_kwargs):
if not isinstance(blob, string_types):
if not isinstance(blob, str):
blob = blob.read()

if blob.startswith('#!'):
Expand Down
3 changes: 1 addition & 2 deletions salt_tower/renderers/yamlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

from salt.utils.yamlloader import SaltYamlSafeLoader, load
from salt.utils.odict import OrderedDict
from salt.ext.six import string_types

try:
from salt.utils.files import fopen
Expand Down Expand Up @@ -121,7 +120,7 @@ def render(source, _saltenv, _sls, **kwargs):
:rtype: A Python data structure
'''
if not isinstance(source, string_types):
if not isinstance(source, str):
source = source.read()

return load(source, Loader=get_yaml_loader(**kwargs))
3 changes: 0 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

[tox]
envlist =
py27-salt{3000,2019,2018,2017,2016}
py3-salt{3000,2019,2018}

[testenv]
Expand All @@ -14,7 +13,5 @@ deps =
salt3000: salt~=3000.0
salt2019: salt~=2019.2.0
salt2018: salt~=2018.3.4
salt2017: salt~=2017.7.8
salt2016: salt~=2016.11.10
commands =
py.test {posargs}

0 comments on commit 2ec449d

Please sign in to comment.