Skip to content
This repository was archived by the owner on Apr 20, 2025. It is now read-only.

Commit 6fe6699

Browse files
hugovksybrenstuvel
authored andcommitted
Upgrade Python syntax with pyupgrade --py38-plus
1 parent 3cd23c1 commit 6fe6699

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

doc/conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
master_doc = 'index'
4444

4545
# General information about the project.
46-
project = u'Python-RSA'
47-
copyright = u'2011-2019, Sybren A. Stüvel'
46+
project = 'Python-RSA'
47+
copyright = '2011-2019, Sybren A. Stüvel'
4848

4949
# The version info for the project you're documenting, acts as replacement for
5050
# |version| and |release|, also used in various other places throughout the
@@ -180,8 +180,8 @@
180180
# Grouping the document tree into LaTeX files. List of tuples
181181
# (source start file, target name, title, author, documentclass [howto/manual]).
182182
latex_documents = [
183-
('index', 'Python-RSA.tex', u'Python-RSA Documentation',
184-
u'Sybren A. Stüvel', 'manual'),
183+
('index', 'Python-RSA.tex', 'Python-RSA Documentation',
184+
'Sybren A. Stüvel', 'manual'),
185185
]
186186

187187
# The name of an image file (relative to this directory) to place at the top of
@@ -213,8 +213,8 @@
213213
# One entry per manual page. List of tuples
214214
# (source start file, name, description, authors, manual section).
215215
man_pages = [
216-
('index', 'python-rsa', u'Python-RSA Documentation',
217-
[u'Sybren A. Stüvel'], 1)
216+
('index', 'python-rsa', 'Python-RSA Documentation',
217+
['Sybren A. Stüvel'], 1)
218218
]
219219

220220
todo_include_todos = True

rsa/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def parse_cli(self) -> typing.Tuple[optparse.Values, typing.List[str]]:
178178
def read_key(self, filename: str, keyform: str) -> rsa.key.AbstractKey:
179179
"""Reads a public or private key."""
180180

181-
print("Reading %s key from %s" % (self.keyname, filename), file=sys.stderr)
181+
print("Reading {} key from {}".format(self.keyname, filename), file=sys.stderr)
182182
with open(filename, "rb") as keyfile:
183183
keydata = keyfile.read()
184184

rsa/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def assert_int(var: int, name: str) -> None:
2323
if isinstance(var, int):
2424
return
2525

26-
raise TypeError("%s should be an integer, not %s" % (name, var.__class__))
26+
raise TypeError("{} should be an integer, not {}".format(name, var.__class__))
2727

2828

2929
def encrypt_int(message: int, ekey: int, n: int) -> int:

rsa/key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _assert_format_exists(
140140
except KeyError as ex:
141141
formats = ", ".join(sorted(methods.keys()))
142142
raise ValueError(
143-
"Unsupported format: %r, try one of %s" % (file_format, formats)
143+
"Unsupported format: {!r}, try one of {}".format(file_format, formats)
144144
) from ex
145145

146146
def save_pkcs1(self, format: str = "PEM") -> bytes:

rsa/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def private_to_public() -> None:
6767
# Read the input data
6868
if cli.infilename:
6969
print(
70-
"Reading private key from %s in %s format" % (cli.infilename, cli.inform),
70+
"Reading private key from {} in {} format".format(cli.infilename, cli.inform),
7171
file=sys.stderr,
7272
)
7373
with open(cli.infilename, "rb") as infile:
@@ -87,7 +87,7 @@ def private_to_public() -> None:
8787

8888
if cli.outfilename:
8989
print(
90-
"Writing public key to %s in %s format" % (cli.outfilename, cli.outform),
90+
"Writing public key to {} in {} format".format(cli.outfilename, cli.outform),
9191
file=sys.stderr,
9292
)
9393
with open(cli.outfilename, "wb") as outfile:

tests/test_cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Unit tests for CLI entry points.
33
"""
44

5-
from __future__ import print_function
65

76
import functools
87
import io

tests/test_strings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414

1515
"""Tests string operations."""
1616

17-
from __future__ import absolute_import
1817

1918
import unittest
2019

2120
import rsa
2221

23-
unicode_string = u"Euro=\u20ac ABCDEFGHIJKLMNOPQRSTUVWXYZ"
22+
unicode_string = "Euro=\u20ac ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2423

2524

2625
class StringTest(unittest.TestCase):

0 commit comments

Comments
 (0)