safer 5.1.0__tar.gz → 5.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,20 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: safer
3
- Version: 5.1.0
3
+ Version: 5.2.0
4
4
  Summary: 🧿 A safer writer for files and streams 🧿
5
- Home-page: https://github.com/rec/safer
6
- License: MIT
7
5
  Author: Tom Ritchford
8
- Author-email: tom@swirly.com
9
- Requires-Python: >=3.8
10
- Classifier: License :: OSI Approved :: MIT License
6
+ Author-email: Tom Ritchford <tom@swirly.com>
7
+ License-Expression: MIT
11
8
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
9
  Classifier: Programming Language :: Python :: 3.10
15
10
  Classifier: Programming Language :: Python :: 3.11
16
11
  Classifier: Programming Language :: Python :: 3.12
17
- Project-URL: Documentation, https://rec.github.io/safer
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Python: >=3.10
15
+ Project-URL: Homepage, https://github.com/rec/safer
18
16
  Project-URL: Repository, https://github.com/rec/safer
17
+ Project-URL: Documentation, https://rec.github.io/safer
19
18
  Description-Content-Type: text/markdown
20
19
 
21
20
  # 🧿 `safer`: A safer writer 🧿
@@ -164,4 +163,3 @@ With `safer`
164
163
 
165
164
 
166
165
  ### [API Documentation](https://rec.github.io/safer#safer--api-documentation)
167
-
@@ -0,0 +1,55 @@
1
+ [project]
2
+ name = "safer"
3
+ version = "5.2.0"
4
+ description = "🧿 A safer writer for files and streams 🧿"
5
+ authors = [{ name = "Tom Ritchford", email = "tom@swirly.com" }]
6
+ requires-python = ">=3.10"
7
+ readme = "README.md"
8
+ license = "MIT"
9
+ classifiers = ["Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14"]
10
+
11
+ [project.urls]
12
+ Homepage = "https://github.com/rec/safer"
13
+ Repository = "https://github.com/rec/safer"
14
+ Documentation = "https://rec.github.io/safer"
15
+
16
+ [dependency-groups]
17
+ dev = [
18
+ "coverage",
19
+ "pytest",
20
+ "readme-renderer",
21
+ "tdir",
22
+ "toml",
23
+ "pyyaml",
24
+ "ruff",
25
+ "pyupgrade>=3.21.2",
26
+ "ty>=0.0.14",
27
+ ]
28
+
29
+ [tool.uv]
30
+
31
+ [tool.uv.build-backend]
32
+ module-root = ""
33
+
34
+ [build-system]
35
+ requires = ["uv_build>=0.9.0,<0.10.0"]
36
+ build-backend = "uv_build"
37
+
38
+ [tool.coverage.run]
39
+ branch = true
40
+ source = ["safer"]
41
+
42
+ [tool.coverage.report]
43
+ fail_under = "90"
44
+ skip_covered = true
45
+ exclude_lines = ["pragma: no cover", "if False:", "if __name__ == .__main__.:", "raise NotImplementedError"]
46
+
47
+ [tool.ruff]
48
+ line-length = 88
49
+
50
+ [tool.ruff.format]
51
+ quote-style = "single"
52
+
53
+
54
+ [tool.doks]
55
+ auto = true
Binary file
@@ -147,6 +147,7 @@ With `safer`
147
147
  # Either the whole file is written, or nothing
148
148
 
149
149
  """
150
+
150
151
  from __future__ import annotations
151
152
 
152
153
  import contextlib
@@ -253,6 +254,7 @@ def writer(
253
254
  raise NotImplementedError(BUG_MESSAGE)
254
255
 
255
256
  def write(v):
257
+ assert isinstance(stream, t.ContextManager), (stream, type(stream))
256
258
  with stream:
257
259
  stream.write(v)
258
260
 
@@ -399,7 +401,7 @@ def open(
399
401
  parent = os.path.dirname(os.path.abspath(name))
400
402
  if not os.path.exists(parent):
401
403
  if not make_parents:
402
- raise IOError('Directory does not exist')
404
+ raise OSError('Directory does not exist')
403
405
  os.makedirs(parent)
404
406
 
405
407
  def simple_open():
@@ -552,7 +554,7 @@ def printer(
552
554
  Same as for `safer.open()`
553
555
  """
554
556
  if 'r' in mode and '+' not in mode:
555
- raise IOError('File not open for writing')
557
+ raise OSError('File not open for writing')
556
558
 
557
559
  if 'b' in mode:
558
560
  raise ValueError('Cannot print to a file open in binary mode')
@@ -598,7 +600,7 @@ class _Closer:
598
600
 
599
601
 
600
602
  # Wrap an existing IO class so that it calls safer at the end
601
- @functools.lru_cache()
603
+ @functools.lru_cache
602
604
  def _wrap_class(stream_cls):
603
605
  @functools.wraps(stream_cls.__exit__)
604
606
  def exit(self, *args):
safer-5.1.0/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Tom Swirly
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,52 +0,0 @@
1
- [tool.poetry]
2
- name = "safer"
3
- version = "5.1.0"
4
- description = "🧿 A safer writer for files and streams 🧿"
5
- authors = ["Tom Ritchford <tom@swirly.com>"]
6
- license = "MIT"
7
- readme = "README.md"
8
- repository = "https://github.com/rec/safer"
9
- homepage = "https://github.com/rec/safer"
10
- documentation = "https://rec.github.io/safer"
11
-
12
- [tool.poetry.dependencies]
13
- python = ">=3.8"
14
-
15
- [tool.poetry.group.dev.dependencies]
16
- coverage = "*"
17
- pytest = "*"
18
- readme-renderer = "*"
19
- tdir = "*"
20
- toml = "*"
21
- pyyaml = "*"
22
- ruff = "*"
23
- mypy = "*"
24
-
25
- [tool.coverage.run]
26
- branch = true
27
- source = ["safer"]
28
-
29
- [tool.coverage.report]
30
- fail_under = "90"
31
- skip_covered = true
32
- exclude_lines = [
33
- "pragma: no cover",
34
- "if False:",
35
- "if __name__ == .__main__.:",
36
- "raise NotImplementedError"
37
- ]
38
-
39
- [tool.ruff]
40
- line-length = 88
41
-
42
- [tool.ruff.format]
43
- quote-style = "single"
44
-
45
-
46
- [tool.mypy]
47
- [build-system]
48
- requires = ["poetry-core"]
49
- build-backend = "poetry.core.masonry.api"
50
-
51
- [tool.doks]
52
- auto = true
File without changes
File without changes