ConfigUpdater 4.0__tar.gz → 4.0.2__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.
Files changed (47) hide show
  1. {configupdater-4.0 → configupdater-4.0.2}/AUTHORS.rst +2 -0
  2. {configupdater-4.0 → configupdater-4.0.2}/CHANGELOG.rst +33 -12
  3. {configupdater-4.0 → configupdater-4.0.2}/CONTRIBUTING.rst +11 -13
  4. {configupdater-4.0 → configupdater-4.0.2}/PKG-INFO +31 -31
  5. {configupdater-4.0 → configupdater-4.0.2}/README.md +30 -30
  6. {configupdater-4.0 → configupdater-4.0.2}/docs/conf.py +6 -0
  7. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/README.md +5 -5
  8. {configupdater-4.0 → configupdater-4.0.2}/docs/index.rst +9 -11
  9. {configupdater-4.0 → configupdater-4.0.2}/docs/usage.rst +17 -17
  10. {configupdater-4.0 → configupdater-4.0.2}/pyproject.toml +1 -1
  11. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/block.py +2 -2
  12. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/configupdater.py +13 -14
  13. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/document.py +21 -20
  14. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/option.py +13 -11
  15. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/parser.py +20 -21
  16. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/section.py +17 -9
  17. {configupdater-4.0 → configupdater-4.0.2}/tests/test_configupdater.py +66 -0
  18. {configupdater-4.0 → configupdater-4.0.2}/tests/test_option.py +64 -0
  19. {configupdater-4.0 → configupdater-4.0.2}/tests/test_section.py +116 -0
  20. {configupdater-4.0 → configupdater-4.0.2}/.gitignore +0 -0
  21. {configupdater-4.0 → configupdater-4.0.2}/LICENSE.txt +0 -0
  22. {configupdater-4.0 → configupdater-4.0.2}/docs/_static/.gitignore +0 -0
  23. {configupdater-4.0 → configupdater-4.0.2}/docs/api.rst +0 -0
  24. {configupdater-4.0 → configupdater-4.0.2}/docs/authors.rst +0 -0
  25. {configupdater-4.0 → configupdater-4.0.2}/docs/changelog.rst +0 -0
  26. {configupdater-4.0 → configupdater-4.0.2}/docs/contributing.rst +0 -0
  27. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/banner-1280x645.png +0 -0
  28. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/banner-640x323.png +0 -0
  29. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/configupdater.svg +0 -0
  30. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/configupdater_plain.svg +0 -0
  31. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/favicon.ico +0 -0
  32. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/icon-92x128.png +0 -0
  33. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/icon.svg +0 -0
  34. {configupdater-4.0 → configupdater-4.0.2}/docs/gfx/sidebar-254x128.png +0 -0
  35. {configupdater-4.0 → configupdater-4.0.2}/docs/license.rst +0 -0
  36. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/__init__.py +0 -0
  37. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/builder.py +0 -0
  38. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/container.py +0 -0
  39. {configupdater-4.0 → configupdater-4.0.2}/src/configupdater/py.typed +0 -0
  40. {configupdater-4.0 → configupdater-4.0.2}/tests/conftest.py +0 -0
  41. {configupdater-4.0 → configupdater-4.0.2}/tests/test_optionxform.py +0 -0
  42. {configupdater-4.0 → configupdater-4.0.2}/tests/test_parser.py +0 -0
  43. {configupdater-4.0 → configupdater-4.0.2}/tests/test_readme.py +0 -0
  44. {configupdater-4.0 → configupdater-4.0.2}/tests/test_setup.cfg +0 -0
  45. {configupdater-4.0 → configupdater-4.0.2}/tools/__init__.py +0 -0
  46. {configupdater-4.0 → configupdater-4.0.2}/tools/release_notes.py +0 -0
  47. {configupdater-4.0 → configupdater-4.0.2}/tools/stdlib_diff.py +0 -0
@@ -10,3 +10,5 @@ Contributors
10
10
  * Sinkleberg
11
11
  * blouirts123 (GitHub)
12
12
  * bysiber (GitHub)
13
+ * civilwarinfrance (GitHub)
14
+ * AlexXuz (GitHub)
@@ -2,10 +2,31 @@
2
2
  Changelog
3
3
  =========
4
4
 
5
+ Version 4.0.2
6
+ =============
7
+
8
+ - Make ``Option.as_list()`` use the current value after assignments to or from
9
+ ``None``, so ``append()`` no longer discards values added to a valueless option
10
+ and converting an option to ``None`` no longer raises an ``AttributeError``, PR #179
11
+ - Detach every child block when clearing a document or section, so removed
12
+ sections and options can be attached elsewhere without stale parent links
13
+ (follow-up to PR #43), PR #180
14
+
15
+ Version 4.0.1
16
+ =============
17
+
18
+ - Insert a newline before a newly added option when the file does not end
19
+ with one, so appending an option to the last section no longer glues the
20
+ option onto the last line and silently corrupts the previous value
21
+ (related to the new-section fix in PR #142 for issue #126), PR #178
22
+ - Fix spelling, grammar and factual errors in the documentation and docstrings,
23
+ e.g. the inverted description of ``empty_lines_in_values`` and the name of the
24
+ unsupported ``defaults`` argument of ConfigParser, PR #175
25
+
5
26
  Version 4.0
6
27
  ===========
7
28
 
8
- - **Breaking:** Drop support for Python < 3.11, the minimum supported version is now
29
+ - **Breaking:** Drop support for Python < 3.11; the minimum supported version is now
9
30
  Python 3.11, PR #150
10
31
  - Add support for Python 3.15, PR #160
11
32
  - Simplify type hints using Python 3.11 features (``typing.Self``, ``X | Y`` unions)
@@ -27,13 +48,13 @@ Version 4.0
27
48
  - Build with hatchling and hatch-vcs, with all metadata in ``pyproject.toml``. The
28
49
  wheel is now tagged ``py3-none-any`` (instead of ``py2.py3-none-any``), and the
29
50
  license is declared as a PEP 639 expression. The ``testing`` extra is removed;
30
- development dependencies are dependency groups, e.g. ``uv sync``, PR #156
51
+ development dependencies are dependency groups, installed e.g. with ``uv sync``, PR #156
31
52
  - Complete the type annotations of the public API, now checked with mypy in strict
32
53
  mode, and fix the ``NoneValueDisallowed`` warning under ``python -OO``, PR #158
33
54
  - Fix ``NotAttachedError``, ``AlreadyAttachedError`` and ``AssignMultilineValueError``
34
55
  failing with an ``AttributeError`` under ``python -OO``, PR #163
35
56
  - Correct the ``NoneValueDisallowed`` message. It claimed that an option without a
36
- value is written with an empty value, but the option is omitted since version 3.0.1,
57
+ value is written with an empty value, but the option has been omitted since version 3.0.1,
37
58
  PR #163
38
59
  - ``add_before.option`` and ``add_after.option`` pass ``delimiter`` and
39
60
  ``space_around_delimiters`` on to the new option instead of silently ignoring all
@@ -71,7 +92,7 @@ Version 3.2
71
92
  ===========
72
93
 
73
94
  - Option ``prepend_newline`` in ``set_values`` to optionally avoid new lines, issue #104
74
- - Fix square brackets not parsed in section names, issue #122
95
+ - Fix square brackets in section names not being parsed, issue #122
75
96
 
76
97
  Version 3.1.1
77
98
  =============
@@ -98,7 +119,7 @@ Version 3.0
98
119
  - Fix parsing error of indented comment lines, issue #25
99
120
  - Allow handling of raw section comment, issue #25
100
121
  - More unit testing of optionxform, issue #55
101
- - Allowing sections/options to be copied from one document to the other, issue #47
122
+ - Allow sections/options to be copied from one document to the other, issue #47
102
123
  - New logo, issue #29
103
124
  - Whole API was rechecked by @abravalheri and changed for consistency, issue #19
104
125
 
@@ -119,17 +140,17 @@ Version 2.0
119
140
  Version 1.1.3
120
141
  =============
121
142
 
122
- - Added fallback option to ConfigUpdater.get reflecting ConfigParser
143
+ - Added ``fallback`` argument to ``ConfigUpdater.get``, mirroring ConfigParser
123
144
 
124
145
  Version 1.1.2
125
146
  =============
126
147
 
127
- - Fix wrongly modifying input in Option.set_value #11
148
+ - Fix wrongly modifying input in ``Option.set_value``, issue #11
128
149
 
129
150
  Version 1.1.1
130
151
  =============
131
152
 
132
- - Fix iterating over the items() view of a section breaks #8
153
+ - Fix iterating over the ``items()`` view of a section, issue #8
133
154
 
134
155
  Version 1.1
135
156
  ===========
@@ -144,17 +165,17 @@ Version 1.0.1
144
165
  =============
145
166
 
146
167
  - More sane error message if ``read_file`` is misused
147
- - Also run unittests with Windows
168
+ - Also run unit tests on Windows
148
169
 
149
170
  Version 1.0
150
171
  ===========
151
172
 
152
- - Fix: Use \n instead of os.linesep where appropriate
173
+ - Fix: Use ``\n`` instead of ``os.linesep`` where appropriate
153
174
 
154
175
  Version 0.3.2
155
176
  =============
156
177
 
157
- - Added Github and documentation link into the project's metadata
178
+ - Added GitHub and documentation links to the project's metadata
158
179
 
159
180
  Version 0.3.1
160
181
  =============
@@ -164,7 +185,7 @@ Version 0.3.1
164
185
  Version 0.3
165
186
  ===========
166
187
 
167
- - Added a ``insert_at`` function at section level
188
+ - Added an ``insert_at`` method at section level
168
189
  - Some internal code simplifications
169
190
 
170
191
  Version 0.2
@@ -3,10 +3,10 @@ Contributing
3
3
  ============
4
4
 
5
5
  ConfigUpdater is an open-source project and needs your help to improve.
6
- If you experience bugs or in general issues, please file an
6
+ If you experience bugs or other issues, please file an
7
7
  issue report on our `issue tracker`_. If you also want to contribute code
8
- or improve the documentation it's best to create a Pull Request (PR) on
9
- Github. Here is a short introduction how it works.
8
+ or improve the documentation, it's best to create a Pull Request (PR) on
9
+ GitHub. Here is a short introduction to how it works.
10
10
 
11
11
 
12
12
  Code Contributions
@@ -15,7 +15,7 @@ Code Contributions
15
15
  Submit an issue
16
16
  ---------------
17
17
 
18
- Before you work on any non-trivial code contribution it's best to first create
18
+ Before you work on any non-trivial code contribution, it's best to first create
19
19
  an issue report to start a discussion on the subject. This often provides
20
20
  additional considerations and avoids unnecessary work.
21
21
 
@@ -29,7 +29,7 @@ version if you don't have one.
29
29
  Clone the repository
30
30
  --------------------
31
31
 
32
- #. `Create a Github account`_ if you do not already have one.
32
+ #. `Create a GitHub account`_ if you do not already have one.
33
33
  #. Fork the `project repository`_: click on the *Fork* button near the top of the
34
34
  page. This creates a copy of the code under your account on the GitHub server.
35
35
  #. Clone this copy to your local disk::
@@ -53,7 +53,7 @@ Clone the repository
53
53
 
54
54
  and start making changes. Never work on the main branch!
55
55
 
56
- #. Start your work on this branch. When you’re done editing, do::
56
+ #. Start your work on this branch. When you're done editing, do::
57
57
 
58
58
  git add modified_files
59
59
  git commit
@@ -68,8 +68,8 @@ Clone the repository
68
68
 
69
69
  or, for a quick run without coverage, ``uv run pytest``.
70
70
 
71
- Don't forget to also add unit tests in case your contribution
72
- adds an additional feature and is not just a bugfix.
71
+ Don't forget to add unit tests for a new feature, and a regression test for
72
+ a bugfix.
73
73
 
74
74
  #. The ``pre-commit`` hooks check your code style with `ruff`_ on every commit.
75
75
  You can also run them on all files with ``uv run tox -e lint``, and check the
@@ -77,14 +77,12 @@ Clone the repository
77
77
  #. Add yourself to the list of contributors in ``AUTHORS.rst``.
78
78
  #. Go to the web page of your ConfigUpdater fork, and click
79
79
  "Create pull request" to send your changes to the maintainers for review.
80
- Find more detailed information `creating a PR`_.
80
+ Find more detailed information on `creating a PR`_.
81
81
 
82
82
 
83
- .. _PyPI: https://pypi.python.org/
84
83
  .. _project repository: https://github.com/pyscaffold/configupdater/
85
- .. _Git: https://git-scm.com/
86
84
  .. _uv: https://docs.astral.sh/uv/getting-started/installation/
87
85
  .. _issue tracker: https://github.com/pyscaffold/configupdater/issues
88
- .. _Create a Github account: https://github.com/join
89
- .. _creating a PR: https://help.github.com/articles/creating-a-pull-request/
86
+ .. _Create a GitHub account: https://github.com/join
87
+ .. _creating a PR: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork
90
88
  .. _ruff: https://docs.astral.sh/ruff/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: ConfigUpdater
3
- Version: 4.0
3
+ Version: 4.0.2
4
4
  Summary: Parser like ConfigParser but for updating configuration files
5
5
  Project-URL: Homepage, https://github.com/pyscaffold/configupdater
6
6
  Project-URL: Documentation, https://configupdater.readthedocs.io/
@@ -28,7 +28,7 @@ Requires-Python: >=3.11
28
28
  Description-Content-Type: text/markdown
29
29
 
30
30
  <div align="center">
31
- <img src="https://raw.githubusercontent.com/pyscaffold/configupdater/master/docs/gfx/banner-640x323.png" alt="Configupdater logo" width="500" role="img">
31
+ <img src="https://raw.githubusercontent.com/pyscaffold/configupdater/main/docs/gfx/banner-640x323.png" alt="ConfigUpdater logo" width="500" role="img">
32
32
  </div>
33
33
  <br/>
34
34
 
@@ -41,27 +41,27 @@ Description-Content-Type: text/markdown
41
41
  The sole purpose of [ConfigUpdater] is to easily
42
42
  update an INI config file with no changes to the original file except
43
43
  the intended ones. This means comments, the ordering of sections and
44
- key/value-pairs as wells as their cases are kept as in the original
44
+ key/value pairs as well as their case are kept as in the original
45
45
  file. Thus ConfigUpdater provides complementary functionality to
46
- Python\'s [ConfigParser], which is primarily meant for reading config
46
+ Python's [ConfigParser], which is primarily meant for reading config
47
47
  files and writing *new* ones.
48
48
 
49
49
  # Features
50
50
 
51
51
  The key differences to [ConfigParser] are:
52
52
 
53
- - minimal invasive changes in the update configuration file,
53
+ - minimally invasive changes in the updated configuration file,
54
54
  - proper handling of comments,
55
55
  - only a single config file can be updated at a time,
56
- - the original case of sections and keys are kept,
57
- - control over the position of a new section/key
56
+ - the original case of sections and keys is kept,
57
+ - control over the position of a new section/key.
58
58
 
59
- Following features are **deliberately not** implemented:
59
+ The following features are **deliberately not** implemented:
60
60
 
61
61
  - interpolation of values,
62
62
  - propagation of parameters from the default section,
63
- - conversions of values,
64
- - passing key/value-pairs with `default` argument,
63
+ - conversion of values,
64
+ - passing key/value pairs with the `defaults` argument,
65
65
  - non-strict mode allowing duplicate sections and keys.
66
66
 
67
67
  # Usage
@@ -114,12 +114,12 @@ the changed configuration file to another destination. Before actually
114
114
  writing, ConfigUpdater will automatically check that the updated
115
115
  configuration file is still valid by parsing it with the help of ConfigParser.
116
116
 
117
- Many of ConfigParser\'s methods still exists and it\'s best to look them
118
- up in the [module reference]. Let\'s look at some examples.
117
+ Many of ConfigParser's methods still exist, and it's best to look them
118
+ up in the [module reference]. Let's look at some examples.
119
119
 
120
120
  ## Adding and removing options
121
121
 
122
- Let\'s say we have the following configuration in a string:
122
+ Let's say we have the following configuration in a string:
123
123
 
124
124
  ```python
125
125
  cfg = """
@@ -129,7 +129,7 @@ summary = The Analytical Engine
129
129
  """
130
130
  ```
131
131
 
132
- We can add an *license* option, i.e. a key/value pair, in the same way
132
+ We can add a *license* option, i.e. a key/value pair, in the same way
133
133
  we would do with ConfigParser:
134
134
 
135
135
  ```python
@@ -138,7 +138,7 @@ updater.read_string(cfg)
138
138
  updater["metadata"]["license"] = "MIT"
139
139
  ```
140
140
 
141
- A simple `print(updater)` will give show you that the new option was
141
+ A simple `print(updater)` will show you that the new option was
142
142
  appended to the end:
143
143
 
144
144
  ```ini
@@ -148,7 +148,7 @@ summary = The Analytical Engine
148
148
  license = MIT
149
149
  ```
150
150
 
151
- Since the license is really important to us let\'s say we want to add it
151
+ Since the license is really important to us, let's say we want to add it
152
152
  before the `summary` and even add a short comment before it:
153
153
 
154
154
  ```python
@@ -183,7 +183,7 @@ updater.read_string(cfg)
183
183
  )
184
184
  ```
185
185
 
186
- Let\'s say we want to rename `summary` to the more common
186
+ Let's say we want to rename `summary` to the more common
187
187
  `description`:
188
188
 
189
189
  ```python
@@ -197,10 +197,10 @@ If we wanted no summary at all, we could just do
197
197
 
198
198
  ## Adding and removing sections
199
199
 
200
- Adding and remove sections just works like adding and removing options
201
- but on a higher level. Sticking to our *Ada Lovelace* example, let\'s
200
+ Adding and removing sections works just like adding and removing options,
201
+ but on a higher level. Sticking to our *Ada Lovelace* example, let's
202
202
  say we want to add a section `options` just before `metadata` with a
203
- comment and two new lines to separate it from `metadata`:
203
+ comment and two blank lines to separate it from `metadata`:
204
204
 
205
205
  ```python
206
206
  updater = ConfigUpdater()
@@ -226,7 +226,7 @@ summary = The Analytical Engine
226
226
  ```
227
227
 
228
228
  We could now fill the new section with options like we learnt before. If
229
- we wanted to rename an existing section we could do this with the help
229
+ we wanted to rename an existing section, we could do this with the help
230
230
  of the `name` attribute:
231
231
 
232
232
  ```python
@@ -234,7 +234,7 @@ updater["metadata"].name = "MetaData"
234
234
  ```
235
235
 
236
236
  Sometimes it might be useful to inject a new section not in a
237
- programmatic way but more declarative. Let\'s assume we have thus
237
+ programmatic way but more declaratively. Let's assume we have thus
238
238
  defined our new section in a multi-line string:
239
239
 
240
240
  ```python
@@ -259,8 +259,8 @@ updater.read_string(cfg)
259
259
  (updater["metadata"].add_after.space().section(sphinx_sect.detach()))
260
260
  ```
261
261
 
262
- The `detach` method will remove the `build_sphinx` section from the
263
- first object and add it to the second object. This results in:
262
+ The `detach` method removes the `build_sphinx` section from the
263
+ first object, so that it can be added to the second one. This results in:
264
264
 
265
265
  ```ini
266
266
  [metadata]
@@ -274,8 +274,8 @@ build_dir = docs/_build
274
274
 
275
275
  Alternatively, if you want to preserve `build_sphinx` in both
276
276
  `ConfigUpdater` objects (i.e., prevent it from being removed from the
277
- first while still adding a copy to the second), you call also rely on
278
- stdlib\'s `copy.deepcopy` function instead of `detach`:
277
+ first while still adding a copy to the second), you can also rely on
278
+ the stdlib's `copy.deepcopy` function instead of `detach`:
279
279
 
280
280
  ```python
281
281
  from copy import deepcopy
@@ -295,12 +295,12 @@ sections, options, comments and blank spaces.
295
295
 
296
296
  Shallow copies are discouraged in the context of ConfigUpdater because
297
297
  each configuration block keeps a reference to its container to allow
298
- easy document editing. When doing editions (such as adding or changing
298
+ easy document editing. When making edits (such as adding or changing
299
299
  options and comments) based on a shallow copy, the results can be
300
300
  unreliable and unexpected.
301
301
 
302
- For more examples on how the API of ConfigUpdater works it\'s best to
303
- take a look into the [unit tests] and read the references.
302
+ For more examples of how the API of ConfigUpdater works, it's best to
303
+ take a look at the [unit tests] and read the [module reference].
304
304
 
305
305
  # Notes
306
306
 
@@ -334,12 +334,12 @@ formatting that humans put into them.
334
334
  [uv-image]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json
335
335
  [uv-link]: https://github.com/astral-sh/uv
336
336
  [ruff-image]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
337
- [ruff-link]: https://github.com/charliermarsh/ruff
337
+ [ruff-link]: https://github.com/astral-sh/ruff
338
338
  [mypy-image]: https://img.shields.io/badge/Types-mypy-blue.svg
339
339
  [mypy-link]: https://mypy-lang.org/
340
340
  [pytest-image]: https://img.shields.io/static/v1?label=‎&message=Pytest&logo=Pytest&color=0A9EDC&logoColor=white
341
341
  [pytest-link]: https://docs.pytest.org/
342
- [rtd-image]: https://readthedocs.org/projects/configupdater/badge/?version=latest
342
+ [rtd-image]: https://img.shields.io/readthedocs/configupdater/latest.svg?logo=readthedocs&logoColor=white&label=Docs
343
343
  [rtd-link]: https://configupdater.readthedocs.io/
344
344
  [precommit-image]: https://img.shields.io/static/v1?label=‎&message=pre-commit&logo=pre-commit&color=76877c
345
345
  [precommit-link]: https://pre-commit.com/
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://raw.githubusercontent.com/pyscaffold/configupdater/master/docs/gfx/banner-640x323.png" alt="Configupdater logo" width="500" role="img">
2
+ <img src="https://raw.githubusercontent.com/pyscaffold/configupdater/main/docs/gfx/banner-640x323.png" alt="ConfigUpdater logo" width="500" role="img">
3
3
  </div>
4
4
  <br/>
5
5
 
@@ -12,27 +12,27 @@
12
12
  The sole purpose of [ConfigUpdater] is to easily
13
13
  update an INI config file with no changes to the original file except
14
14
  the intended ones. This means comments, the ordering of sections and
15
- key/value-pairs as wells as their cases are kept as in the original
15
+ key/value pairs as well as their case are kept as in the original
16
16
  file. Thus ConfigUpdater provides complementary functionality to
17
- Python\'s [ConfigParser], which is primarily meant for reading config
17
+ Python's [ConfigParser], which is primarily meant for reading config
18
18
  files and writing *new* ones.
19
19
 
20
20
  # Features
21
21
 
22
22
  The key differences to [ConfigParser] are:
23
23
 
24
- - minimal invasive changes in the update configuration file,
24
+ - minimally invasive changes in the updated configuration file,
25
25
  - proper handling of comments,
26
26
  - only a single config file can be updated at a time,
27
- - the original case of sections and keys are kept,
28
- - control over the position of a new section/key
27
+ - the original case of sections and keys is kept,
28
+ - control over the position of a new section/key.
29
29
 
30
- Following features are **deliberately not** implemented:
30
+ The following features are **deliberately not** implemented:
31
31
 
32
32
  - interpolation of values,
33
33
  - propagation of parameters from the default section,
34
- - conversions of values,
35
- - passing key/value-pairs with `default` argument,
34
+ - conversion of values,
35
+ - passing key/value pairs with the `defaults` argument,
36
36
  - non-strict mode allowing duplicate sections and keys.
37
37
 
38
38
  # Usage
@@ -85,12 +85,12 @@ the changed configuration file to another destination. Before actually
85
85
  writing, ConfigUpdater will automatically check that the updated
86
86
  configuration file is still valid by parsing it with the help of ConfigParser.
87
87
 
88
- Many of ConfigParser\'s methods still exists and it\'s best to look them
89
- up in the [module reference]. Let\'s look at some examples.
88
+ Many of ConfigParser's methods still exist, and it's best to look them
89
+ up in the [module reference]. Let's look at some examples.
90
90
 
91
91
  ## Adding and removing options
92
92
 
93
- Let\'s say we have the following configuration in a string:
93
+ Let's say we have the following configuration in a string:
94
94
 
95
95
  ```python
96
96
  cfg = """
@@ -100,7 +100,7 @@ summary = The Analytical Engine
100
100
  """
101
101
  ```
102
102
 
103
- We can add an *license* option, i.e. a key/value pair, in the same way
103
+ We can add a *license* option, i.e. a key/value pair, in the same way
104
104
  we would do with ConfigParser:
105
105
 
106
106
  ```python
@@ -109,7 +109,7 @@ updater.read_string(cfg)
109
109
  updater["metadata"]["license"] = "MIT"
110
110
  ```
111
111
 
112
- A simple `print(updater)` will give show you that the new option was
112
+ A simple `print(updater)` will show you that the new option was
113
113
  appended to the end:
114
114
 
115
115
  ```ini
@@ -119,7 +119,7 @@ summary = The Analytical Engine
119
119
  license = MIT
120
120
  ```
121
121
 
122
- Since the license is really important to us let\'s say we want to add it
122
+ Since the license is really important to us, let's say we want to add it
123
123
  before the `summary` and even add a short comment before it:
124
124
 
125
125
  ```python
@@ -154,7 +154,7 @@ updater.read_string(cfg)
154
154
  )
155
155
  ```
156
156
 
157
- Let\'s say we want to rename `summary` to the more common
157
+ Let's say we want to rename `summary` to the more common
158
158
  `description`:
159
159
 
160
160
  ```python
@@ -168,10 +168,10 @@ If we wanted no summary at all, we could just do
168
168
 
169
169
  ## Adding and removing sections
170
170
 
171
- Adding and remove sections just works like adding and removing options
172
- but on a higher level. Sticking to our *Ada Lovelace* example, let\'s
171
+ Adding and removing sections works just like adding and removing options,
172
+ but on a higher level. Sticking to our *Ada Lovelace* example, let's
173
173
  say we want to add a section `options` just before `metadata` with a
174
- comment and two new lines to separate it from `metadata`:
174
+ comment and two blank lines to separate it from `metadata`:
175
175
 
176
176
  ```python
177
177
  updater = ConfigUpdater()
@@ -197,7 +197,7 @@ summary = The Analytical Engine
197
197
  ```
198
198
 
199
199
  We could now fill the new section with options like we learnt before. If
200
- we wanted to rename an existing section we could do this with the help
200
+ we wanted to rename an existing section, we could do this with the help
201
201
  of the `name` attribute:
202
202
 
203
203
  ```python
@@ -205,7 +205,7 @@ updater["metadata"].name = "MetaData"
205
205
  ```
206
206
 
207
207
  Sometimes it might be useful to inject a new section not in a
208
- programmatic way but more declarative. Let\'s assume we have thus
208
+ programmatic way but more declaratively. Let's assume we have thus
209
209
  defined our new section in a multi-line string:
210
210
 
211
211
  ```python
@@ -230,8 +230,8 @@ updater.read_string(cfg)
230
230
  (updater["metadata"].add_after.space().section(sphinx_sect.detach()))
231
231
  ```
232
232
 
233
- The `detach` method will remove the `build_sphinx` section from the
234
- first object and add it to the second object. This results in:
233
+ The `detach` method removes the `build_sphinx` section from the
234
+ first object, so that it can be added to the second one. This results in:
235
235
 
236
236
  ```ini
237
237
  [metadata]
@@ -245,8 +245,8 @@ build_dir = docs/_build
245
245
 
246
246
  Alternatively, if you want to preserve `build_sphinx` in both
247
247
  `ConfigUpdater` objects (i.e., prevent it from being removed from the
248
- first while still adding a copy to the second), you call also rely on
249
- stdlib\'s `copy.deepcopy` function instead of `detach`:
248
+ first while still adding a copy to the second), you can also rely on
249
+ the stdlib's `copy.deepcopy` function instead of `detach`:
250
250
 
251
251
  ```python
252
252
  from copy import deepcopy
@@ -266,12 +266,12 @@ sections, options, comments and blank spaces.
266
266
 
267
267
  Shallow copies are discouraged in the context of ConfigUpdater because
268
268
  each configuration block keeps a reference to its container to allow
269
- easy document editing. When doing editions (such as adding or changing
269
+ easy document editing. When making edits (such as adding or changing
270
270
  options and comments) based on a shallow copy, the results can be
271
271
  unreliable and unexpected.
272
272
 
273
- For more examples on how the API of ConfigUpdater works it\'s best to
274
- take a look into the [unit tests] and read the references.
273
+ For more examples of how the API of ConfigUpdater works, it's best to
274
+ take a look at the [unit tests] and read the [module reference].
275
275
 
276
276
  # Notes
277
277
 
@@ -305,12 +305,12 @@ formatting that humans put into them.
305
305
  [uv-image]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json
306
306
  [uv-link]: https://github.com/astral-sh/uv
307
307
  [ruff-image]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
308
- [ruff-link]: https://github.com/charliermarsh/ruff
308
+ [ruff-link]: https://github.com/astral-sh/ruff
309
309
  [mypy-image]: https://img.shields.io/badge/Types-mypy-blue.svg
310
310
  [mypy-link]: https://mypy-lang.org/
311
311
  [pytest-image]: https://img.shields.io/static/v1?label=‎&message=Pytest&logo=Pytest&color=0A9EDC&logoColor=white
312
312
  [pytest-link]: https://docs.pytest.org/
313
- [rtd-image]: https://readthedocs.org/projects/configupdater/badge/?version=latest
313
+ [rtd-image]: https://img.shields.io/readthedocs/configupdater/latest.svg?logo=readthedocs&logoColor=white&label=Docs
314
314
  [rtd-link]: https://configupdater.readthedocs.io/
315
315
  [precommit-image]: https://img.shields.io/static/v1?label=‎&message=pre-commit&logo=pre-commit&color=76877c
316
316
  [precommit-link]: https://pre-commit.com/
@@ -4,6 +4,7 @@ The package must be installed (``uv run tox -e docs`` and Read the Docs do that)
4
4
  autodoc imports the same code that is shipped.
5
5
  """
6
6
 
7
+ import os
7
8
  from datetime import date
8
9
  from importlib.metadata import version as get_version
9
10
 
@@ -24,6 +25,7 @@ extensions = [
24
25
  "sphinx.ext.napoleon",
25
26
  "sphinx.ext.viewcode",
26
27
  "sphinx_copybutton",
28
+ "sphinxcontrib.googleanalytics",
27
29
  ]
28
30
 
29
31
  root_doc = "index"
@@ -57,3 +59,7 @@ html_theme_options = {
57
59
  "source_branch": "main",
58
60
  "source_directory": "docs/",
59
61
  }
62
+
63
+ # Google Analytics 4, only on Read the Docs, so local builds don't send any data
64
+ googleanalytics_id = "G-P7XJCP7XJ7"
65
+ googleanalytics_enabled = os.environ.get("READTHEDOCS") == "True"
@@ -1,11 +1,11 @@
1
- The logo design uses the Monoid typeface a open source webfont that was
1
+ The logo design uses the Monoid typeface, an open-source web font that was
2
2
  developed by Andreas Larsen and contributors in 2015 under the MIT or SIL
3
3
  licenses.
4
4
  More information at https://github.com/larsenwork/monoid
5
5
 
6
6
  The colors include pure black (`#000000`), pure white (`#FFFFFF`), 30% gray for the
7
7
  box shadow (`#B3B3B3`) and an accent color (`#008C70`) that can be understood as a
8
- tone of "teal"
8
+ tone of "teal".
9
9
 
10
10
  A vector representation of the design can be found in the files:
11
11
 
@@ -13,7 +13,7 @@ A vector representation of the design can be found in the files:
13
13
  contain specific markup not understood by other software. This file
14
14
  should be preferred when using Inkscape.
15
15
  - `configupdater_plain.svg`: a "plain" version of the same file that in theory
16
- should not contain inkscape-specific markup. This file might be preferred
16
+ should not contain Inkscape-specific markup. This file might be preferred
17
17
  when using other editors.
18
- - `icon.svg`: another Inkscape file that only contains, this time without the
19
- "ConfigUpdater" name, just the icon image.
18
+ - `icon.svg`: another Inkscape file that only contains the icon image, this time
19
+ without the "ConfigUpdater" name.
@@ -9,9 +9,9 @@
9
9
 
10
10
  The sole purpose of `ConfigUpdater`_ is to easily update an INI config file
11
11
  with no changes to the original file except the intended ones. This means
12
- comments, the ordering of sections and key/value-pairs as wells as their
13
- cases are kept as in the original file. Thus ConfigUpdater provides
14
- complementary functionality to Python's `ConfigParser`_ which is primarily
12
+ comments, the ordering of sections and key/value pairs as well as their
13
+ case are kept as in the original file. Thus ConfigUpdater provides
14
+ complementary functionality to Python's `ConfigParser`_, which is primarily
15
15
  meant for reading config files and writing *new* ones.
16
16
  Read more on how to use `ConfigUpdater`_ in the :ref:`usage page <usage>`.
17
17
 
@@ -20,18 +20,18 @@ Features
20
20
 
21
21
  The key differences to `ConfigParser`_ are:
22
22
 
23
- * minimal invasive changes in the update configuration file,
23
+ * minimally invasive changes in the updated configuration file,
24
24
  * proper handling of comments,
25
25
  * only a single config file can be updated at a time,
26
- * the original case of sections and keys are kept,
27
- * control over the position of a new section/key
26
+ * the original case of sections and keys is kept,
27
+ * control over the position of a new section/key.
28
28
 
29
- Following features are **deliberately not** implemented:
29
+ The following features are **deliberately not** implemented:
30
30
 
31
31
  * interpolation of values,
32
32
  * propagation of parameters from the default section,
33
- * conversions of values,
34
- * passing key/value-pairs with ``default`` argument,
33
+ * conversion of values,
34
+ * passing key/value pairs with the ``defaults`` argument,
35
35
  * non-strict mode allowing duplicate sections and keys.
36
36
 
37
37
  .. note::
@@ -45,8 +45,6 @@ Following features are **deliberately not** implemented:
45
45
  .. _ConfigParser: https://docs.python.org/3/library/configparser.html
46
46
  .. _ConfigUpdater: https://configupdater.readthedocs.io/
47
47
  .. _PyScaffold: https://pyscaffold.org/
48
- .. _module reference: https://configupdater.readthedocs.io/en/latest/api/configupdater.html#configupdater.configupdater.ConfigUpdater
49
- .. _unit tests: https://github.com/pyscaffold/configupdater/blob/main/tests/test_configupdater.py
50
48
 
51
49
 
52
50