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

Change the language type given to CatalogRepository in tests #12853

Merged

Conversation

adamtheturtle
Copy link
Contributor

@adamtheturtle adamtheturtle commented Sep 1, 2024

Some tests gave None as the language.
The CatalogRepository signature says that language should be a str:

class CatalogRepository:
    """A repository for message catalogs."""

    def __init__(self, basedir: str | os.PathLike[str], locale_dirs: list[str],
                 language: str, encoding: str) -> None:

I also looked at whether the language type should be changed to str | None. I believe that it should not - outside of tests, the only callers (within Sphinx) of CatalogRepository.__init__ pass in self.config.language, where config is a sphinx.config.Config.

Looking at that, I see:

...

config_values: dict[str, _Opt] = {
    ...
    'language': _Opt('en', 'env', frozenset((str,))),
}

This shows that the valid types at the config level do not include types.NoneType.

Some tests gave `None` as the language.
The `CatalogRepository` signature says that `language` should be a `str`:

```python
class CatalogRepository:
    """A repository for message catalogs."""

    def __init__(self, basedir: str | os.PathLike[str], locale_dirs: list[str],
                 language: str, encoding: str) -> None:
```

I also looked at whether the `language` type should be changed to `str | None`.
I believe that it should not - outside of tests, the only callers (within Sphinx)
of `CatalogRepository.__init__` pass in `self.config.language`, where `config` is
a `sphinx.config.Config`.

Looking at that, I see:

```python

...

config_values: dict[str, _Opt] = {
    ...
    'language': _Opt('en', 'env', frozenset((str,))),
}
```

This shows that the valid types at the config level do not include `types.NoneType`.
@AA-Turner AA-Turner merged commit 15aadd6 into sphinx-doc:master Sep 2, 2024
22 checks passed
@adamtheturtle adamtheturtle deleted the catalog-repository-tests branch September 2, 2024 13:42
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

Successfully merging this pull request may close these issues.

2 participants