Skip to content

Relax the signature of logging.config.loadConfig #6577

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

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

JukkaL
Copy link
Contributor

@JukkaL JukkaL commented Dec 13, 2021

I did a a cursory investigation using GitHub search and also looked at
a big internal codebase, and a significant fraction of callsites used
a dict type instead of a TypedDict or a dict literal.

It seems that it's a common use case to store the config within an
attribute. For example, something like this:

CONFIG = {
   ...
}

...
logging.config.dictConfig(CONFIG)

Another use case that was not properly supported is reading the
config from a file, and the config is given dict[str, Any] as
the type.

Mypy can still do some type checking of the argument if called
with a dict literal, so I feel this is a reasonable compromise
between type checking strictness and usability.

I did a a cursory investigation using GitHub search and also looked at
a big internal codebase, and a significant fraction of callsites used
a dict type instead of a TypedDict or a dict literal.

It seems that it's a common use case to store the config within an
attribute. For example, something like this:

```
CONFIG = {
   ...
}

...
logging.config.dictConfig(CONFIG)
```

Another use case that was not properly supported is reading the
config from a file, and the config is given `dict[str, Any]` as
the type.

Mypy can still do some type checking of the argument if called
with a dict literal, so I feel this is a reasonable compromise
between type checking strictness and usability.
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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