Commit graph

7 commits

Author SHA1 Message Date
sobolevn
cb3174113e
gh-133117: Enable stricter mypy checks for tomllib (#133206) 2025-05-03 16:57:09 +03:00
sobolevn
5ea9010e89
gh-133117: Run mypy on tomllib in CI (#133118) 2025-04-30 11:45:58 +03:00
Taneli Hukkinen
ea6cc26e75
gh-118761: Improve import time of tomllib (#128907)
Improve import time of `tomllib`  (in sync with upstream)
2025-01-16 18:48:42 -08:00
Taneli Hukkinen
29b5323c45
gh-126175: Add attributes to TOMLDecodeError. Deprecate free-form __init__ args (GH-126428) 2024-11-13 13:52:16 +01:00
Taneli Hukkinen
67f5c5bd6f
tomllib: Add a comment about implicit lru_cache bound (GH-126078) 2024-10-29 11:36:14 +01:00
Taneli Hukkinen
9ce90206b7
gh-124835: tomllib.loads: Raise TypeError not AttributeError. Improve message (#124587) 2024-10-01 19:58:08 -07:00
Taneli Hukkinen
591f6754b5
bpo-40059: Add tomllib (PEP-680) (GH-31498)
This adds a new standard library module, `tomllib`, for parsing TOML.

The implementation is based on Tomli (https://github.com/hukkin/tomli).

## Steps taken (converting `tomli` to `tomllib`)

- Move everything in `tomli:src/tomli` to `Lib/tomllib`. Exclude `py.typed`.
- Remove `__version__ = ...` line from `Lib/tomllib/__init__.py`
- Move everything in `tomli:tests` to `Lib/test/test_tomllib`. Exclude the following test data dirs recursively:
  - `tomli:tests/data/invalid/_external/`
  - `tomli:tests/data/valid/_external/`
- Create `Lib/test/test_tomllib/__main__.py`:

  ```python
  import unittest

  from . import load_tests


  unittest.main()
  ```


- Add the following to `Lib/test/test_tomllib/__init__.py`:

  ```python
  import os
  from test.support import load_package_tests

  def load_tests(*args):
      return load_package_tests(os.path.dirname(__file__), *args)
  ```

  Also change `import tomli as tomllib` to `import tomllib`.

- In `cpython/Lib/tomllib/_parser.py` replace `__fp` with `fp` and `__s` with
  `s`. Add the `/` to `load` and `loads` function signatures.

- Run `make regen-stdlib-module-names`

- Create `Doc/library/tomllib.rst` and reference it in `Doc/library/fileformats.rst`
2022-03-08 09:26:13 +01:00