Skip to content

Commit ba1acac

Browse files
committed
really drop python<=3.7 support
Filter all code over `pyupgracde --py38-plus`. Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
1 parent ca046f4 commit ba1acac

File tree

13 files changed

+41
-43
lines changed

13 files changed

+41
-43
lines changed

docs/custom_extensions/requires_rfc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def setup(app):
88
app.add_role('requires-ext', RequiresExtRole(app))
99

1010

11-
class RequiresExtRole(object):
11+
class RequiresExtRole:
1212
def __init__(self, app):
1313
self.app = app
1414

docs/source/conf.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Python-GSSAPI documentation build configuration file, created by
43
# sphinx-quickstart on Tue Jul 2 19:01:09 2013.
@@ -58,8 +57,8 @@
5857
master_doc = 'index'
5958

6059
# General information about the project.
61-
project = u'Python-GSSAPI'
62-
copyright = u'2014, The Python-GSSAPI team'
60+
project = 'Python-GSSAPI'
61+
copyright = '2014, The Python-GSSAPI team'
6362

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

106-
with open(setup_py_path, mode='r') as fd:
105+
with open(setup_py_path) as fd:
107106
for line in fd:
108107
version_match = version_pattern.match(line)
109108
if version_match:
@@ -249,8 +248,8 @@
249248
# Grouping the document tree into LaTeX files. List of tuples
250249
# (source start file, target name, title, author, documentclass [howto/manual]).
251250
latex_documents = [
252-
('index', 'Python-GSSAPI.tex', u'Python-GSSAPI Documentation',
253-
u'The Python-GSSAPI team', 'manual'),
251+
('index', 'Python-GSSAPI.tex', 'Python-GSSAPI Documentation',
252+
'The Python-GSSAPI team', 'manual'),
254253
]
255254

256255
# The name of an image file (relative to this directory) to place at the top of
@@ -293,8 +292,8 @@
293292
# (source start file, target name, title, author,
294293
# dir menu entry, description, category)
295294
texinfo_documents = [
296-
('index', 'Python-GSSAPI', u'Python-GSSAPI Documentation',
297-
u'The Python-GSSAPI team', 'Python-GSSAPI',
295+
('index', 'Python-GSSAPI', 'Python-GSSAPI Documentation',
296+
'The Python-GSSAPI team', 'Python-GSSAPI',
298297
'One line description of project.', 'Miscellaneous'),
299298
]
300299

gssapi/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def import_gssapi_extension(
2828
"""
2929

3030
try:
31-
path = 'gssapi.raw.ext_{0}'.format(name)
31+
path = f'gssapi.raw.ext_{name}'
3232
__import__(path)
3333
return sys.modules[path]
3434
except ImportError:
@@ -192,4 +192,4 @@ def __new__(
192192
if attr_name[0] != '_':
193193
attrs[attr_name] = check_last_err(attr)
194194

195-
return super(CheckLastError, cls).__new__(cls, name, parents, attrs)
195+
return super().__new__(cls, name, parents, attrs)

gssapi/creds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __new__(
7979
base_creds = res.creds
8080

8181
return t.cast("Credentials",
82-
super(Credentials, cls).__new__(cls, base_creds))
82+
super().__new__(cls, base_creds))
8383

8484
@property
8585
def name(self) -> rnames.Name:

gssapi/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(
2424
) -> None:
2525
maj_str = self.MAJOR_MESSAGE.format(**kwargs)
2626
err_str = self.FMT_STR.format(maj=maj_str, min=minor_message)
27-
super(GeneralError, self).__init__(err_str)
27+
super().__init__(err_str)
2828

2929

3030
class UnknownUsageError(GeneralError):
@@ -42,6 +42,6 @@ def __init__(
4242
unwrapped_message: t.Optional[bytes] = None,
4343
**kwargs: str,
4444
) -> None:
45-
super(EncryptionNotUsed, self).__init__(minor_message, **kwargs)
45+
super().__init__(minor_message, **kwargs)
4646

4747
self.unwrapped_message = unwrapped_message

gssapi/mechs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __new__(
2727
elements: t.Optional[bytes] = None,
2828
) -> "Mechanism":
2929
return t.cast("Mechanism",
30-
super(Mechanism, cls).__new__(cls, cpy, elements))
30+
super().__new__(cls, cpy, elements))
3131

3232
@property
3333
def name_types(self) -> t.Set[roids.OID]:
@@ -73,7 +73,7 @@ def __repr__(self) -> str:
7373
"""
7474
base = "<Mechanism (%s)>" % self.dotted_form
7575
if rfc5801 is not None:
76-
base = "<Mechanism %s (%s)>" % (
76+
base = "<Mechanism {} ({})>".format(
7777
self._saslname.mech_name.decode('UTF-8'),
7878
self.dotted_form
7979
)
@@ -203,11 +203,11 @@ def from_attrs(
203203
:requires-ext:`rfc5587`
204204
"""
205205
if isinstance(desired_attrs, roids.OID):
206-
desired_attrs = set([desired_attrs])
206+
desired_attrs = {desired_attrs}
207207
if isinstance(except_attrs, roids.OID):
208-
except_attrs = set([except_attrs])
208+
except_attrs = {except_attrs}
209209
if isinstance(critical_attrs, roids.OID):
210-
critical_attrs = set([critical_attrs])
210+
critical_attrs = {critical_attrs}
211211

212212
if rfc5587 is None:
213213
raise NotImplementedError("Your GSSAPI implementation does not "

gssapi/names.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import typing as t
32

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

82-
return t.cast("Name", super(Name, cls).__new__(cls, base_name))
81+
return t.cast("Name", super().__new__(cls, base_name))
8382

8483
def __init__(
8584
self,

gssapi/raw/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
# NB(directxman12): the enum extensions must be imported BEFORE ANYTHING ELSE!
4343
for modinf in pkgutil.iter_modules(_enum_extensions.__path__):
4444
name = modinf[1]
45-
importlib.import_module('{0}._enum_extensions.{1}'.format(__name__, name))
45+
importlib.import_module(f'{__name__}._enum_extensions.{name}')
4646

4747
del pkgutil
4848
del importlib

gssapi/raw/_enum_extensions/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __new__(
3333
else:
3434
classdict[extra_name] = extra_val
3535

36-
return super(ExtendableEnum, metacl).__new__(
36+
return super().__new__(
3737
metacl,
3838
name,
3939
bases,

gssapi/sec_contexts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __new__(
4646
base = rsec_contexts.import_sec_context(token)
4747

4848
return t.cast("SecurityContext",
49-
super(SecurityContext, cls).__new__(cls, base))
49+
super().__new__(cls, base))
5050

5151
def __init__(
5252
self,

gssapi/tests/test_high_level.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class _GSSAPIKerberosTestCase(kt.KerberosTestCase):
3131
@classmethod
3232
def setUpClass(cls):
33-
super(_GSSAPIKerberosTestCase, cls).setUpClass()
33+
super().setUpClass()
3434
svc_princ = SERVICE_PRINCIPAL.decode("UTF-8")
3535

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

5959
@classmethod
6060
def tearDownClass(cls):
61-
super(_GSSAPIKerberosTestCase, cls).tearDownClass()
61+
super().tearDownClass()
6262
cls._restore_env()
6363

6464

@@ -94,7 +94,7 @@ def exist_perms(**kwargs):
9494
perms = _perms_cycle(curr_elems.pop(), curr_elems, {})
9595
res = []
9696
for name_str, perm in perms:
97-
args = dict([(k, v) for (k, v) in kwargs.items() if perm[k]])
97+
args = {k: v for (k, v) in kwargs.items() if perm[k]}
9898
res.append((name_str, args))
9999

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

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

183183
@ktu.gssapi_extension_test('cred_store', 'credentials store')
184184
def test_store_into_acquire_from(self):
185-
CCACHE = 'FILE:{tmpdir}/other_ccache'.format(tmpdir=self.realm.tmpdir)
186-
KT = '{tmpdir}/other_keytab'.format(tmpdir=self.realm.tmpdir)
185+
CCACHE = f'FILE:{self.realm.tmpdir}/other_ccache'
186+
KT = f'{self.realm.tmpdir}/other_keytab'
187187
store = {'ccache': CCACHE, 'keytab': KT}
188188

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

282282
@ktu.gssapi_extension_test('cred_store', 'credentials store')
283283
def test_store_into_add_from(self):
284-
CCACHE = 'FILE:{tmpdir}/other_ccache'.format(tmpdir=self.realm.tmpdir)
285-
KT = '{tmpdir}/other_keytab'.format(tmpdir=self.realm.tmpdir)
284+
CCACHE = f'FILE:{self.realm.tmpdir}/other_ccache'
285+
KT = f'{self.realm.tmpdir}/other_keytab'
286286
store = {'ccache': CCACHE, 'keytab': KT}
287287

288288
princ_name = 'service_add_from/cs@' + self.realm.realm
@@ -536,7 +536,7 @@ def test_create_from_composite_token_with_attrs(self):
536536
self.assertIsNotNone(name2)
537537

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

@@ -647,7 +647,7 @@ def test_basic_get_set_del_name_attribute_no_auth(self):
647647

648648
canon_name.attributes['urn:greet:greeting'] = (b'some val', True)
649649
ugg = canon_name.attributes["urn:greet:greeting"]
650-
self.assertEqual(ugg.values, set([b"some val"]))
650+
self.assertEqual(ugg.values, {b"some val"})
651651
self.assertTrue(ugg.complete)
652652
self.assertFalse(ugg.authenticated)
653653

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

663663
class SecurityContextTestCase(_GSSAPIKerberosTestCase):
664664
def setUp(self):
665-
super(SecurityContextTestCase, self).setUp()
665+
super().setUp()
666666
gssctx.SecurityContext.__DEFER_STEP_ERRORS__ = False
667667
self.client_name = gssnames.Name(self.USER_PRINC)
668668
self.client_creds = gsscreds.Credentials(name=None,

gssapi/tests/test_raw.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
class _GSSAPIKerberosTestCase(kt.KerberosTestCase):
2828
@classmethod
2929
def setUpClass(cls):
30-
super(_GSSAPIKerberosTestCase, cls).setUpClass()
30+
super().setUpClass()
3131
svc_princ = SERVICE_PRINCIPAL.decode("UTF-8")
3232

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

5757
@classmethod
5858
def tearDownClass(cls):
59-
super(_GSSAPIKerberosTestCase, cls).tearDownClass()
59+
super().tearDownClass()
6060
cls._restore_env()
6161

6262

@@ -449,8 +449,8 @@ def test_store_cred_acquire_cred(self):
449449

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

@@ -660,7 +660,7 @@ def test_rfc5587(self):
660660
known_attrs_dict[mech_attr].add(mech)
661661

662662
for attr, expected_mechs in attrs_dict.items():
663-
attrs = set([attr])
663+
attrs = {attr}
664664

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

678678
mechs = gb.indicate_mechs_by_attrs(None, None, attrs)
679679
self.assertGreater(len(mechs), 0)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def get_output(*args, **kwargs):
3939
autodetect_kc = False
4040
print(f"Using {kc} from env")
4141

42-
link_args, compile_args = [
42+
link_args, compile_args = (
4343
shlex.split(os.environ[e], posix=posix) if e in os.environ else None
4444
for e in ['GSSAPI_LINKER_ARGS', 'GSSAPI_COMPILER_ARGS']
45-
]
45+
)
4646

4747
osx_has_gss_framework = False
4848
if sys.platform == 'darwin':

0 commit comments

Comments
 (0)