Skip to content

Commit f18ed30

Browse files
authored
docs: fix encoding; clarify example is for setup.cfg (#266)
1 parent ca6b491 commit f18ed30

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/pages/patterns/data_files.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ data file, the naïve solution is just to hard-code the path to that file.
5656
```python
5757
from pathlib import Path
5858

59-
spacings_txt = Path("peak_spacings/LaB6.txt").read_text(encoding="utf=8")
59+
spacings_txt = Path("peak_spacings/LaB6.txt").read_text(encoding="utf-8")
6060
```
6161

6262
But this is not a good solution because:
@@ -111,7 +111,8 @@ package.peak_spacings =
111111
```
112112

113113
**Or**, you can use automatic data inclusion (this is the default if you use
114-
`pyproject.toml` `[project]` config in Setuptools 61+):
114+
`pyproject.toml` `[project]` config in Setuptools 61+). To enable this with
115+
`setup.cfg`:
115116

116117
```ini
117118
[options]
@@ -139,7 +140,7 @@ import importlib_resources as resources
139140

140141
ref = resources.files("package.peak_spacings") / "LaB6.txt"
141142

142-
spacings_txt = ref.read_text(encoding="utf=8")
143+
spacings_txt = ref.read_text(encoding="utf-8")
143144

144145
# If you have an API that requires an on-disk file, you can do this instead:
145146
with resources.as_file(ref) as path:

0 commit comments

Comments
 (0)