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

Emergent typing failure #14

Closed
jaraco opened this issue Mar 31, 2024 · 8 comments
Closed

Emergent typing failure #14

jaraco opened this issue Mar 31, 2024 · 8 comments

Comments

@jaraco
Copy link
Owner

jaraco commented Mar 31, 2024

Recently, the mypy type checks started failing with the error:

37: error: Cannot override class variable (previously declared on base class "Directive") with instance variable  [misc]

The relevant code is:

class SidebarLinksDirective(sphinx.util.docutils.SphinxDirective):
"""
Directive which adds a toctree to the sidebar containing links to the project home
and PyPI repo.
"""
has_content: bool = True
option_spec = {
"pypi": directives.flag,
"home": directives.flag,
"caption": directives.unchanged_required,
}

And I traced the definition of that class property to:

https://github.com/docutils/docutils/blob/b768e2626088711dec257b0847b563d02700a712/docutils/docutils/parsers/rst/__init__.py#L316-L317

Essentially:

class Directive:
    has_content = False
    """May the directive have content?"""

I don't yet understand how SidebarLinksDirective is an instance variable.

@jaraco
Copy link
Owner Author

jaraco commented Mar 31, 2024

Here's what Gemini had to say about it. Basically, mypy is being unnecessarily nitpicky that I'm using the interface provided by docutils.

@jaraco
Copy link
Owner Author

jaraco commented Mar 31, 2024

The code passed as recently as 3 months ago.

@jaraco
Copy link
Owner Author

jaraco commented Mar 31, 2024

Downgrading mypy to 1.7.1 from November, the issue still occurs, so likely the difference is with the typespec for docutils.

@jaraco
Copy link
Owner Author

jaraco commented Mar 31, 2024

Docutils 0.20.1 from last May is still stable.

@jaraco
Copy link
Owner Author

jaraco commented Mar 31, 2024

types-docutils appears to have frequent releases. What a mess.

@jaraco
Copy link
Owner Author

jaraco commented Mar 31, 2024

Starting with https://pypi.org/project/types-docutils/0.20.0.20240310/, the tests start failing.

@danieleades
Copy link

types-docutils appears to have frequent releases. What a mess.

All typeshed libraries are released daily (whenever they have changes).

If this is an issue you can pin the version

@jaraco
Copy link
Owner Author

jaraco commented Mar 31, 2024

types-docutils appears to have frequent releases. What a mess.

All typeshed libraries are released daily (whenever they have changes).

If this is an issue you can pin the version

Thanks for clarifying, and apologies for being abrasive. I thought what I was looking at was a bunch of insignificant changes, assuming that it wasn't possible for a mostly stable module like docutils to evolve so rapidly, but I now see there are rapid and meaningful changes. I'm grateful for that work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants