Thanks all for the feedback, concerns, or support.
Pressure to adopt this
It’s true that there could be a potential pressure to adopt this just for being a PEP, yep, I understand it, I can see how it could happen.
And indeed, if editors and tooling ended up giving better support to this just for being a PEP than the support they currently give to alternatives, resulting in a better developer experience, I can see how that could easily become something users would want and put pressure to have it.
And for people editing the documentation part, as editors already have good support for standard Python syntax, there’s a high chance they would end up preferring this, despite it meaning moving the verbosity from the docstring in the function body to the signature.
Yet another standard
About it being “yet another competing standard”, it’s true, it is, just like pyproject.toml. But it has a few key differences with current approaches, including standard Python syntax and direct runtime access, I’ll update the PEP to make that a bit more clear with a list of the specific “features” of this proposal.
Readability
About comparing the readability and editability of one of the common docstring formats vs this, I think that’s quite subjective. To me, this is actually more readable, with syntax highlighting separating the types and their docstrings. I would expect this could be more readable and editable for newcomers that still don’t know with full expertise any of Sphinx, Numpydoc, or Google-style.
So I would personally consider this a bit more welcoming and open to newcomers, the same way editing pyproject.toml is so much more convenient than it was using setuptools (one of the big reasons why I never built something before pyproject.toml).
But again, if this is a friendlier and better developer experience for newcomers or not is deeply subjective. And no one here is a newcomer, only seasoned experts with well-defined mental models and docstring expertise, so we don’t have a way to know how this would feel for others before trying. I just have an intuition that this would be useful for a wider audience than just me, the same intuition that has led me to build anything else I have.
Fortunately we have typing_extensions just for that:
Enable experimentation with new type system PEPs before they are accepted
That way we can see how useful (if at all) this is and if the drawbacks are worth it.
Go to definition
I also commonly go to the definition of libraries I use, and I have contributed to/or explored other libraries, e.g. SQLAlchemy, which has very long docstrings. And I remember scrolling pages of docstrings before arriving at the implementation. I remember I ended up editing the docstring for another function just because it was so far way from the signature that I ended up scrolling past it and ended up in the next function.
So, I would think readability and usability can be a bit subjective. I think several comments imply that if the documentation is in the docstring it would no longer consume characters and space, or it would no longer be verbose, or would be more readable. Also, when I read a docstring, I don’t have full certainty that it’s updated and has the right documentation for the current parameters. Sometimes it can get out of sync, missing a parameter or keeping one that was removed. That has also happened to me when using mainstream libraries. If you could simply omit all docstrings, then yes, all the code would be quite short, but I personally don’t consider docstrings and documentation in general as something independent and maybe far away from the implementation… If I was reading the implementation of someone’s library, I would actually like to be able to see the docs for some parameter or return type right there, next to the implementation, I would find that more readable. But again, that’s subjective. In the end, it’s about tradeoffs and priorities. And what has higher importance for each person.
I can see that, for some, it has a much higher priority to quickly read/edit the signature of a function, without seeing its documentation in the same place, than anything else. In your own library or in external libraries. Nothing wrong with that, just personal preference.