Skip to content

Commit 5b8c4c9

Browse files
authored
Revisited the supported Python versions up to 3.10 (#13)
We dropped the checks for Python 3.5 and added checks for 3.9 and 3.10, respectively, in the continuous integration. Python 3.5 reached the end-of-life already some time ago. We also upgraded mypy and pylint to the latest versions since the old versions did not work with Python 3.9 and 3.10.
1 parent 82fa1eb commit 5b8c4c9

5 files changed

Lines changed: 18 additions & 16 deletions

File tree

.github/workflows/check-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [3.5, 3.6, 3.7, 3.8]
10+
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
1111

1212
steps:
1313
- uses: actions/checkout@master

.github/workflows/check-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [3.5, 3.6, 3.7, 3.8]
13+
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
1414

1515
steps:
1616
- uses: actions/checkout@master

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
'Development Status :: 5 - Production/Stable',
2929
'Intended Audience :: Developers',
3030
'License :: OSI Approved :: MIT License',
31-
'Programming Language :: Python :: 3.5',
3231
'Programming Language :: Python :: 3.6',
3332
'Programming Language :: Python :: 3.7',
3433
'Programming Language :: Python :: 3.8',
34+
'Programming Language :: Python :: 3.9',
35+
'Programming Language :: Python :: 3.10',
3536
# yapf: enable
3637
],
3738
keywords='tempfile pathlib temporary file directory mkdtemp mkstemp',
@@ -40,8 +41,8 @@
4041
extras_require={
4142
'dev': [
4243
# yapf: disable
43-
'mypy==0.790',
44-
'pylint==2.6.0',
44+
'mypy==0.941',
45+
'pylint==2.12.2',
4546
'yapf==0.20.2',
4647
'tox>=3,<4',
4748
'coverage>=5,<6',

temppathlib/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, path: Union[str, pathlib.Path]) -> None:
1616
elif isinstance(path, pathlib.Path):
1717
self.path = path
1818
else:
19-
raise ValueError("Unexpected type of 'path': {}".format(type(path)))
19+
raise ValueError(f"Unexpected type of 'path': {type(path)}")
2020

2121
def __enter__(self) -> pathlib.Path:
2222
"""Give back the path that will be removed."""
@@ -75,7 +75,7 @@ def __init__(self,
7575
elif isinstance(base_tmp_dir, str):
7676
self.base_tmp_dir = pathlib.Path(base_tmp_dir)
7777
else:
78-
raise ValueError("Unexpected type of 'base_tmp_dir': {}".format(type(base_tmp_dir)))
78+
raise ValueError(f"Unexpected type of 'base_tmp_dir': {type(base_tmp_dir)}")
7979

8080
self._path = None # type: Optional[pathlib.Path]
8181

@@ -86,7 +86,7 @@ def __init__(self,
8686
elif isinstance(path, pathlib.Path):
8787
self._path = path
8888
else:
89-
raise ValueError("Unexpected type for the argument `path`: {}".format(type(path)))
89+
raise ValueError(f"Unexpected type for the argument `path`: {type(path)}")
9090

9191
self.dont_delete = dont_delete_tmp_dir
9292

@@ -102,7 +102,7 @@ def path(self) -> pathlib.Path:
102102
"""Get the underlying path or raise if the path has not been set."""
103103
if self._path is None:
104104
raise RuntimeError("The _path has not been set. "
105-
"Are you using {} outside of the context management?".format(self.__class__.__name__))
105+
f"Are you using {self.__class__.__name__} outside of the context management?")
106106

107107
return self._path
108108

@@ -156,7 +156,7 @@ def __init__(self,
156156
elif isinstance(base_tmp_dir, str):
157157
self.base_tmp_dir = pathlib.Path(base_tmp_dir)
158158
else:
159-
raise ValueError("Unexpected type of 'base_tmp_dir': {}".format(type(base_tmp_dir)))
159+
raise ValueError(f"Unexpected type of 'base_tmp_dir': {type(base_tmp_dir)}")
160160

161161
self.prefix = prefix
162162
self.dont_delete = dont_delete
@@ -176,7 +176,7 @@ def path(self) -> pathlib.Path:
176176
"""Get the underlying path or raise if the path has not been set."""
177177
if self._path is None:
178178
raise RuntimeError("The _path has not been set. "
179-
"Are you using {} outside of the context management?".format(self.__class__.__name__))
179+
f"Are you using {self.__class__.__name__} outside of the context management?")
180180

181181
return self._path
182182

@@ -231,6 +231,7 @@ def __init__(
231231
232232
:param delete: whether the file is deleted on close (default True).
233233
"""
234+
# pylint: disable=consider-using-with
234235
self.__tmpfile = tempfile.NamedTemporaryFile(
235236
mode=mode,
236237
buffering=buffering,
@@ -243,7 +244,7 @@ def __init__(
243244

244245
self.path = pathlib.Path(self.__tmpfile.name)
245246

246-
file = self.__tmpfile.file # type: ignore
247+
file = self.__tmpfile.file
247248
self.file = file # type: IO[Any]
248249
self.delete = delete
249250

tests/test_temppathlib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_that_it_works(self) -> None:
2424
self.assertTrue(pth.exists())
2525

2626
subpth = pth / 'oi.txt'
27-
with subpth.open('wt') as fid:
27+
with subpth.open('wt', encoding='utf-8') as fid:
2828
fid.write('hey!')
2929
fid.flush()
3030

@@ -45,20 +45,20 @@ def test_no_enter(self) -> None:
4545
dir2 = tmp_dir / "dir2"
4646
dir2.mkdir()
4747

48-
names = sorted(list([pth.name for pth in tmp_dir.iterdir()]))
48+
names = sorted(pth.name for pth in tmp_dir.iterdir())
4949
self.assertListEqual(names, ['dir1', 'dir2'])
5050

5151
# context manager invoked without enter does not delete the path.
5252
temppathlib.removing_tree(path=dir1)
5353

54-
names = sorted(list([pth.name for pth in tmp_dir.iterdir()]))
54+
names = sorted(pth.name for pth in tmp_dir.iterdir())
5555
self.assertListEqual(names, ['dir1', 'dir2'])
5656

5757
# context manager invoked with enter does delete the path.
5858
with temppathlib.removing_tree(path=dir1):
5959
pass
6060

61-
names = sorted(list([pth.name for pth in tmp_dir.iterdir()]))
61+
names = sorted(pth.name for pth in tmp_dir.iterdir())
6262
self.assertListEqual(names, ['dir2'])
6363
finally:
6464
if tmp_dir.exists():

0 commit comments

Comments
 (0)