# PEP 722/723 decision

**URL:** <https://discuss.python.org/t/pep-722-723-decision/36763>\
**Category:** Standards\
**Tags:** pep\
**Created:** [October 21, 2023, 12:23am UTC](https://discuss.python.org/t/pep-722-723-decision/36763 "2023-10-21T00:23:20Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![DavidCEllis](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/davidcellis/32/9789_2.png) [@DavidCEllis](https://discuss.python.org/u/DavidCEllis)\
**Post date:** [October 22, 2023, 9:00am UTC](https://discuss.python.org/t/pep-722-723-decision/36763/6 "2023-10-22T09:00:11Z")

</div>

Thanks to Brett, Ofek, Paul and Courtney for their work on the two PEPs.

I put together a [quick parser](https://github.com/DavidCEllis/ducktools-pep723parser) yesterday and I wanted to check it against the [reference implementation given in the pep](https://peps.python.org/pep-0723/#reference-implementation). However it seems that the reference implementation for reading a block doesn’t work and gives an `AttributeError` unless I’m missing something?

> **Reference Code**
>
> ```python
> import re
> import tomllib
> 
> REGEX = r'(?m)^# /// (?P<type>[a-zA-Z0-9-]+)$\s(?P<content>(^#(| .*)$\s)+)^# ///$'
> 
> def read(script: str) -> dict | None:
> name = 'pyproject'
> matches = list(
> filter(lambda m: m.group('type') == name, re.finditer(REGEX, script))
> )
> if len(matches) > 1:
> raise ValueError(f'Multiple {name} blocks found')
> elif len(matches) == 1:
> return tomllib.loads(matches[0])
> else:
> return None
> 
> sample = """
> # /// pyproject
> # [run]
> # requires-python = ">=3.11"
> # dependencies = [
> # "requests<3",
> # "rich",
> # ]
> # ///
> """
> 
> print(read(sample))
> 
> ```

Output:

```auto
AttributeError: 're.Match' object has no attribute 'replace'

```

It looks like it needs to extract the block from the re.match and remove the "# " from each line before passing to `tomllib.loads`. Something like:

```python
    elif len(matches) == 1:
        content = matches[0].group("content")
        data = "\n".join(line[2:] for line in content.split("\n"))
        return tomllib.loads(data)

```

---

_[View the full topic](https://discuss.python.org/t/pep-722-723-decision/36763)._
