Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify docutils type annotations #12007

Closed
18 of 22 tasks
danieleades opened this issue Feb 25, 2024 · 11 comments · Fixed by #12012
Closed
18 of 22 tasks

Unify docutils type annotations #12007

danieleades opened this issue Feb 25, 2024 · 11 comments · Fixed by #12012
Labels
docutils Tags upstream Docutils issues internals:typing

Comments

@danieleades
Copy link
Contributor

danieleades commented Feb 25, 2024

there are two sources of truth for docutils type annotations.

this repo uses docutils-stubs, but there's also typeshed annotations - types-docutils.

Neither are complete, nor is one a subset of the other. types-docutils was historically pretty poor but has seen more active development lately and has improved. doctuils-stubs is more complete, but is out of date and unmaintained.

I believe this repo should migrate to the typeshed annotations and upstream anything missing from docutils-stubs into typeshed.

cc @tk0miya

and the actual PR to migrate to typeshed (WIP): #12012

@danieleades
Copy link
Contributor Author

Have started tweaking type annotations in typeshed, with a view to reach parity and then transition this repo to typeshed

python/typeshed#11468

@picnixz
Copy link
Member

picnixz commented Feb 26, 2024

Good idea! I am always frustrated because of how poor autocompletion is done with docutils on Pycharm so I'll be very happy if this can be merged upstream.

@danieleades
Copy link
Contributor Author

i've created a PR to track the migration here - #12012

contributions (both to the PR and upstream in typeshed) very very welcome!

@danieleades
Copy link
Contributor Author

danieleades commented Mar 3, 2024

@sphinx-doc/triagers @sphinx-doc/developers @sphinx-doc/former-maintainers @picnixz

can I pretty please get a solid review of python/typeshed#11469?

It introduces a generic type argument to the docutils state machine to represent the context. That generic argument will propogate through into a massive number of docutils types so is a significant change. Before that happens I want to check this is correct!
I'm not super familiar with the inner workings of the docutils statemachines. Is the 'context' truly generic? what is its type?

from the docutils docs:

context: application-specific storage.

@picnixz
Copy link
Member

picnixz commented Mar 3, 2024

I won't be there next week, and I don't think I'll have time for that today. But I'll do it by in two weeks (I will take time for that).

@jayaddison jayaddison added the docutils Tags upstream Docutils issues label Mar 3, 2024
@danieleades
Copy link
Contributor Author

@sphinx-doc/triagers @sphinx-doc/developers @sphinx-doc/former-maintainers @picnixz

can I pretty please get a solid review of python/typeshed#11469?

It introduces a generic type argument to the docutils state machine to represent the context. That generic argument will propogate through into a massive number of docutils types so is a significant change. Before that happens I want to check this is correct! I'm not super familiar with the inner workings of the docutils statemachines. Is the 'context' truly generic? what is its type?

from the docutils docs:

context: application-specific storage.

stand down!

I've postponed adding generics, even if they are technically correct. The decision is blocking progress and would have significant downstream impact.
I'll revisit in a separate PR and just type the context as Any for now

@chrisjsewell
Copy link
Member

Is the 'context' truly generic?

If you are talking about state transitions, like def blank(self, match, context, next_state):, then context is a list[str]

I'm not super familiar with the inner workings of the docutils statemachines

I am, I've been through it in excruciating detail, because I'm writing an RST parser as we speak 😉

This all looks great, thanks for all the work!
... although obviously it would be a million time easier, if we could just type docutils itself 😅

@danieleades
Copy link
Contributor Author

If you are talking about state transitions, like def blank(self, match, context, next_state):, then context is a list[str]

I believe that's true of the rst-specific subclasses. Is it also true of the superclass? (I'll take your word for it)

@picnixz
Copy link
Member

picnixz commented Mar 4, 2024

Ah thank you chris for helping here since I am travelling (I'm currently in a train). Could I ask you to help with the upstream PRs (I can come back later if there are some questions though it's been a while since I played with docutils)?

@chrisjsewell
Copy link
Member

Could I ask you to help with the upstream PRs

Okie, I will try to carve out some time for it 👍

@danieleades
Copy link
Contributor Author

i'm proposing that #12012 be merged, warts and all so that all future improvements to typing are made against the community-supported typeshed docutils stubs

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
docutils Tags upstream Docutils issues internals:typing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants