-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Increase static typing strictness #10530
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
Changes from all commits
ae759f4
f65241a
3449e9b
8834ab7
e98bac9
6616779
95105f1
d62b576
59dc8d1
35542cd
c373bd0
08f0a42
c2eedd7
0bf4d55
7377de1
b4a92ac
c1ed2fb
63a803e
4657261
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||
| import codecs | ||||||
| import pickle | ||||||
| import time | ||||||
| import warnings | ||||||
| from os import path | ||||||
| from typing import (TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, | ||||||
| Type, Union) | ||||||
|
|
@@ -11,6 +12,7 @@ | |||||
| from docutils.nodes import Node | ||||||
|
|
||||||
| from sphinx.config import Config | ||||||
| from sphinx.deprecation import RemovedInSphinx70Warning | ||||||
| from sphinx.environment import CONFIG_CHANGED_REASON, CONFIG_OK, BuildEnvironment | ||||||
| from sphinx.environment.adapters.asset import ImageAdapter | ||||||
| from sphinx.errors import SphinxError | ||||||
|
|
@@ -75,15 +77,22 @@ class Builder: | |||||
| #: The builder supports data URIs or not. | ||||||
| supported_data_uri_images = False | ||||||
|
|
||||||
| def __init__(self, app: "Sphinx") -> None: | ||||||
| def __init__(self, app: "Sphinx", env: BuildEnvironment = None) -> None: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I'm using A
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's not how this works. Setting a default value of It's better to be explicit and use the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added A
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it should be an error with that config. Not sure why you're not seeing one, could be you're hitting the maximum number of errors, or it could be a false negative. In either case you should be able to convince yourself from the documentation that using the explicit
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah i think i see the issue. you have this- strict_optional = False
no_implicit_optional = Trueto see these errors your would need strict_optional = True
no_implicit_optional = Trueif you really want to give yourself nightmares, try strict = True |
||||||
| self.srcdir = app.srcdir | ||||||
| self.confdir = app.confdir | ||||||
| self.outdir = app.outdir | ||||||
| self.doctreedir = app.doctreedir | ||||||
| ensuredir(self.doctreedir) | ||||||
|
|
||||||
| self.app: Sphinx = app | ||||||
| self.env: Optional[BuildEnvironment] = None | ||||||
| if env is not None: | ||||||
| self.env: BuildEnvironment = env | ||||||
| self.env.set_versioning_method(self.versioning_method, | ||||||
| self.versioning_compare) | ||||||
| elif env is not Ellipsis: | ||||||
| # ... is passed by SphinxComponentRegistry.create_builder to not show two warnings. | ||||||
| warnings.warn("The 'env' argument to Builder will be required from Sphinx 7.", | ||||||
| RemovedInSphinx70Warning, stacklevel=2) | ||||||
| self.events: EventManager = app.events | ||||||
| self.config: Config = app.config | ||||||
| self.tags: Tags = app.tags | ||||||
|
|
@@ -105,6 +114,9 @@ def __init__(self, app: "Sphinx") -> None: | |||||
|
|
||||||
| def set_environment(self, env: BuildEnvironment) -> None: | ||||||
| """Store BuildEnvironment object.""" | ||||||
| warnings.warn("Builder.set_environment is deprecated, pass env to " | ||||||
| "'Builder.__init__()' instead.", | ||||||
| RemovedInSphinx70Warning, stacklevel=2) | ||||||
| self.env = env | ||||||
| self.env.set_versioning_method(self.versioning_method, | ||||||
| self.versioning_compare) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |||||
| from sphinx.config import ENUM, Config | ||||||
| from sphinx.deprecation import RemovedInSphinx70Warning, deprecated_alias | ||||||
| from sphinx.domains import Domain, Index, IndexEntry | ||||||
| from sphinx.environment import BuildEnvironment | ||||||
| from sphinx.environment.adapters.asset import ImageAdapter | ||||||
| from sphinx.environment.adapters.indexentries import IndexEntries | ||||||
| from sphinx.environment.adapters.toctree import TocTree | ||||||
|
|
@@ -51,6 +52,17 @@ | |||||
| logger = logging.getLogger(__name__) | ||||||
| return_codes_re = re.compile('[\r\n]+') | ||||||
|
|
||||||
| DOMAIN_INDEX_TYPE = Tuple[ | ||||||
| # Index name (e.g. py-modindex) | ||||||
| str, | ||||||
| # Index class | ||||||
| Type[Index], | ||||||
| # list of (heading string, list of index entries) pairs. | ||||||
| List[Tuple[str, List[IndexEntry]]], | ||||||
| # whether sub-entries should start collapsed | ||||||
| bool | ||||||
| ] | ||||||
|
|
||||||
|
|
||||||
| def get_stable_hash(obj: Any) -> str: | ||||||
| """ | ||||||
|
|
@@ -197,10 +209,10 @@ class StandaloneHTMLBuilder(Builder): | |||||
| download_support = True # enable download role | ||||||
|
|
||||||
| imgpath: str = None | ||||||
| domain_indices: List[Tuple[str, Type[Index], List[Tuple[str, List[IndexEntry]]], bool]] = [] # NOQA | ||||||
| domain_indices: List[DOMAIN_INDEX_TYPE] = [] | ||||||
|
|
||||||
| def __init__(self, app: Sphinx) -> None: | ||||||
| super().__init__(app) | ||||||
| def __init__(self, app: Sphinx, env: BuildEnvironment = None) -> None: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| super().__init__(app, env) | ||||||
|
|
||||||
| # CSS files | ||||||
| self.css_files: List[Stylesheet] = [] | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.