Skip to content

Commit

Permalink
really drop python<=3.7 support
Browse files Browse the repository at this point in the history
Filter all code over `pyupgracde --py38-plus`.

Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
  • Loading branch information
kloczek committed Oct 3, 2024
1 parent ca046f4 commit ba1acac
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion docs/custom_extensions/requires_rfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def setup(app):
app.add_role('requires-ext', RequiresExtRole(app))


class RequiresExtRole(object):
class RequiresExtRole:
def __init__(self, app):
self.app = app

Expand Down
15 changes: 7 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Python-GSSAPI documentation build configuration file, created by
# sphinx-quickstart on Tue Jul 2 19:01:09 2013.
Expand Down Expand Up @@ -58,8 +57,8 @@
master_doc = 'index'

# General information about the project.
project = u'Python-GSSAPI'
copyright = u'2014, The Python-GSSAPI team'
project = 'Python-GSSAPI'
copyright = '2014, The Python-GSSAPI team'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -103,7 +102,7 @@
# The full version, including alpha/beta/rc tags.
release = ''

with open(setup_py_path, mode='r') as fd:
with open(setup_py_path) as fd:
for line in fd:
version_match = version_pattern.match(line)
if version_match:
Expand Down Expand Up @@ -249,8 +248,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Python-GSSAPI.tex', u'Python-GSSAPI Documentation',
u'The Python-GSSAPI team', 'manual'),
('index', 'Python-GSSAPI.tex', 'Python-GSSAPI Documentation',
'The Python-GSSAPI team', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -293,8 +292,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Python-GSSAPI', u'Python-GSSAPI Documentation',
u'The Python-GSSAPI team', 'Python-GSSAPI',
('index', 'Python-GSSAPI', 'Python-GSSAPI Documentation',
'The Python-GSSAPI team', 'Python-GSSAPI',
'One line description of project.', 'Miscellaneous'),
]

Expand Down
4 changes: 2 additions & 2 deletions gssapi/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def import_gssapi_extension(
"""

try:
path = 'gssapi.raw.ext_{0}'.format(name)
path = f'gssapi.raw.ext_{name}'
__import__(path)
return sys.modules[path]
except ImportError:
Expand Down Expand Up @@ -192,4 +192,4 @@ def __new__(
if attr_name[0] != '_':
attrs[attr_name] = check_last_err(attr)

return super(CheckLastError, cls).__new__(cls, name, parents, attrs)
return super().__new__(cls, name, parents, attrs)
2 changes: 1 addition & 1 deletion gssapi/creds.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __new__(
base_creds = res.creds

return t.cast("Credentials",
super(Credentials, cls).__new__(cls, base_creds))
super().__new__(cls, base_creds))

@property
def name(self) -> rnames.Name:
Expand Down
4 changes: 2 additions & 2 deletions gssapi/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(
) -> None:
maj_str = self.MAJOR_MESSAGE.format(**kwargs)
err_str = self.FMT_STR.format(maj=maj_str, min=minor_message)
super(GeneralError, self).__init__(err_str)
super().__init__(err_str)


class UnknownUsageError(GeneralError):
Expand All @@ -42,6 +42,6 @@ def __init__(
unwrapped_message: t.Optional[bytes] = None,
**kwargs: str,
) -> None:
super(EncryptionNotUsed, self).__init__(minor_message, **kwargs)
super().__init__(minor_message, **kwargs)

self.unwrapped_message = unwrapped_message
10 changes: 5 additions & 5 deletions gssapi/mechs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __new__(
elements: t.Optional[bytes] = None,
) -> "Mechanism":
return t.cast("Mechanism",
super(Mechanism, cls).__new__(cls, cpy, elements))
super().__new__(cls, cpy, elements))

@property
def name_types(self) -> t.Set[roids.OID]:
Expand Down Expand Up @@ -73,7 +73,7 @@ def __repr__(self) -> str:
"""
base = "<Mechanism (%s)>" % self.dotted_form
if rfc5801 is not None:
base = "<Mechanism %s (%s)>" % (
base = "<Mechanism {} ({})>".format(
self._saslname.mech_name.decode('UTF-8'),
self.dotted_form
)
Expand Down Expand Up @@ -203,11 +203,11 @@ def from_attrs(
:requires-ext:`rfc5587`
"""
if isinstance(desired_attrs, roids.OID):
desired_attrs = set([desired_attrs])
desired_attrs = {desired_attrs}
if isinstance(except_attrs, roids.OID):
except_attrs = set([except_attrs])
except_attrs = {except_attrs}
if isinstance(critical_attrs, roids.OID):
critical_attrs = set([critical_attrs])
critical_attrs = {critical_attrs}

if rfc5587 is None:
raise NotImplementedError("Your GSSAPI implementation does not "
Expand Down
3 changes: 1 addition & 2 deletions gssapi/names.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import typing as t

from gssapi.raw import names as rname
Expand Down Expand Up @@ -79,7 +78,7 @@ def __new__(
base, # type: ignore[arg-type]
name_type)

return t.cast("Name", super(Name, cls).__new__(cls, base_name))
return t.cast("Name", super().__new__(cls, base_name))

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion gssapi/raw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# NB(directxman12): the enum extensions must be imported BEFORE ANYTHING ELSE!
for modinf in pkgutil.iter_modules(_enum_extensions.__path__):
name = modinf[1]
importlib.import_module('{0}._enum_extensions.{1}'.format(__name__, name))
importlib.import_module(f'{__name__}._enum_extensions.{name}')

del pkgutil
del importlib
Expand Down
2 changes: 1 addition & 1 deletion gssapi/raw/_enum_extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __new__(
else:
classdict[extra_name] = extra_val

return super(ExtendableEnum, metacl).__new__(
return super().__new__(
metacl,
name,
bases,
Expand Down
2 changes: 1 addition & 1 deletion gssapi/sec_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __new__(
base = rsec_contexts.import_sec_context(token)

return t.cast("SecurityContext",
super(SecurityContext, cls).__new__(cls, base))
super().__new__(cls, base))

def __init__(
self,
Expand Down
22 changes: 11 additions & 11 deletions gssapi/tests/test_high_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class _GSSAPIKerberosTestCase(kt.KerberosTestCase):
@classmethod
def setUpClass(cls):
super(_GSSAPIKerberosTestCase, cls).setUpClass()
super().setUpClass()
svc_princ = SERVICE_PRINCIPAL.decode("UTF-8")

cls.realm.kinit(svc_princ, flags=['-k'])
Expand Down Expand Up @@ -58,7 +58,7 @@ def _restore_env(cls):

@classmethod
def tearDownClass(cls):
super(_GSSAPIKerberosTestCase, cls).tearDownClass()
super().tearDownClass()
cls._restore_env()


Expand Down Expand Up @@ -94,7 +94,7 @@ def exist_perms(**kwargs):
perms = _perms_cycle(curr_elems.pop(), curr_elems, {})
res = []
for name_str, perm in perms:
args = dict([(k, v) for (k, v) in kwargs.items() if perm[k]])
args = {k: v for (k, v) in kwargs.items() if perm[k]}
res.append((name_str, args))

return parameterized.expand(res)
Expand All @@ -114,7 +114,7 @@ def true_false_perms(*all_elems_tuple):
# NB(directxman12): the above note used to be wonderfully sarcastic
class CredsTestCase(_GSSAPIKerberosTestCase):
def setUp(self):
super(CredsTestCase, self).setUp()
super().setUp()

svc_princ = SERVICE_PRINCIPAL.decode("UTF-8")
self.realm.kinit(svc_princ, flags=['-k'])
Expand Down Expand Up @@ -182,8 +182,8 @@ def test_store_acquire(self):

@ktu.gssapi_extension_test('cred_store', 'credentials store')
def test_store_into_acquire_from(self):
CCACHE = 'FILE:{tmpdir}/other_ccache'.format(tmpdir=self.realm.tmpdir)
KT = '{tmpdir}/other_keytab'.format(tmpdir=self.realm.tmpdir)
CCACHE = f'FILE:{self.realm.tmpdir}/other_ccache'
KT = f'{self.realm.tmpdir}/other_keytab'
store = {'ccache': CCACHE, 'keytab': KT}

princ_name = 'service/cs@' + self.realm.realm
Expand Down Expand Up @@ -281,8 +281,8 @@ def test_add(self):

@ktu.gssapi_extension_test('cred_store', 'credentials store')
def test_store_into_add_from(self):
CCACHE = 'FILE:{tmpdir}/other_ccache'.format(tmpdir=self.realm.tmpdir)
KT = '{tmpdir}/other_keytab'.format(tmpdir=self.realm.tmpdir)
CCACHE = f'FILE:{self.realm.tmpdir}/other_ccache'
KT = f'{self.realm.tmpdir}/other_keytab'
store = {'ccache': CCACHE, 'keytab': KT}

princ_name = 'service_add_from/cs@' + self.realm.realm
Expand Down Expand Up @@ -536,7 +536,7 @@ def test_create_from_composite_token_with_attrs(self):
self.assertIsNotNone(name2)

ugg = name2.attributes["urn:greet:greeting"]
self.assertEqual(ugg.values, set([b"some val"]))
self.assertEqual(ugg.values, {b"some val"})
self.assertTrue(ugg.complete)
self.assertFalse(ugg.authenticated)

Expand Down Expand Up @@ -647,7 +647,7 @@ def test_basic_get_set_del_name_attribute_no_auth(self):

canon_name.attributes['urn:greet:greeting'] = (b'some val', True)
ugg = canon_name.attributes["urn:greet:greeting"]
self.assertEqual(ugg.values, set([b"some val"]))
self.assertEqual(ugg.values, {b"some val"})
self.assertTrue(ugg.complete)
self.assertFalse(ugg.authenticated)

Expand All @@ -662,7 +662,7 @@ def test_basic_get_set_del_name_attribute_no_auth(self):

class SecurityContextTestCase(_GSSAPIKerberosTestCase):
def setUp(self):
super(SecurityContextTestCase, self).setUp()
super().setUp()
gssctx.SecurityContext.__DEFER_STEP_ERRORS__ = False
self.client_name = gssnames.Name(self.USER_PRINC)
self.client_creds = gsscreds.Credentials(name=None,
Expand Down
12 changes: 6 additions & 6 deletions gssapi/tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class _GSSAPIKerberosTestCase(kt.KerberosTestCase):
@classmethod
def setUpClass(cls):
super(_GSSAPIKerberosTestCase, cls).setUpClass()
super().setUpClass()
svc_princ = SERVICE_PRINCIPAL.decode("UTF-8")

cls.realm.kinit(svc_princ, flags=['-k'])
Expand Down Expand Up @@ -56,7 +56,7 @@ def _restore_env(cls):

@classmethod
def tearDownClass(cls):
super(_GSSAPIKerberosTestCase, cls).tearDownClass()
super().tearDownClass()
cls._restore_env()


Expand Down Expand Up @@ -449,8 +449,8 @@ def test_store_cred_acquire_cred(self):

@ktu.gssapi_extension_test('cred_store', 'credentials store')
def test_store_cred_into_acquire_cred(self):
CCACHE = 'FILE:{tmpdir}/other_ccache'.format(tmpdir=self.realm.tmpdir)
KT = '{tmpdir}/other_keytab'.format(tmpdir=self.realm.tmpdir)
CCACHE = f'FILE:{self.realm.tmpdir}/other_ccache'
KT = f'{self.realm.tmpdir}/other_keytab'
store = {b'ccache': CCACHE.encode('UTF-8'),
b'keytab': KT.encode('UTF-8')}

Expand Down Expand Up @@ -660,7 +660,7 @@ def test_rfc5587(self):
known_attrs_dict[mech_attr].add(mech)

for attr, expected_mechs in attrs_dict.items():
attrs = set([attr])
attrs = {attr}

mechs = gb.indicate_mechs_by_attrs(attrs, None, None)
self.assertGreater(len(mechs), 0)
Expand All @@ -673,7 +673,7 @@ def test_rfc5587(self):
if self.realm.provider.lower() != 'heimdal':
# Heimdal doesn't fully implement gss_indicate_mechs_by_attrs
for attr, expected_mechs in known_attrs_dict.items():
attrs = set([attr])
attrs = {attr}

mechs = gb.indicate_mechs_by_attrs(None, None, attrs)
self.assertGreater(len(mechs), 0)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def get_output(*args, **kwargs):
autodetect_kc = False
print(f"Using {kc} from env")

link_args, compile_args = [
link_args, compile_args = (
shlex.split(os.environ[e], posix=posix) if e in os.environ else None
for e in ['GSSAPI_LINKER_ARGS', 'GSSAPI_COMPILER_ARGS']
]
)

osx_has_gss_framework = False
if sys.platform == 'darwin':
Expand Down

0 comments on commit ba1acac

Please sign in to comment.