wemake-services / django-split-settings

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.
http://django-split-settings.rtfd.io
BSD 3-Clause "New" or "Revised" License
1.11k stars 67 forks source link

Argument to optional has incompatible type #507

Closed SukiCZ closed 11 months ago

SukiCZ commented 11 months ago

Hello,

My understanding of optional is, that it can include a file conditionally. I have a settings file like this:

from os import environ
from split_settings.tools import optional, include

ENV_PRODUCTION = 'production'
ENV_LOCAL = 'local'

ENV = environ['DJANGO_ENV']

include(
    'base.py',
    optional('local_settings.py' if ENV == ENV_LOCAL else None),
)

Unfortunately, when running mypy, I get this error:

error: Argument 1 to "optional" has incompatible type "str | None"; expected "str"  [arg-type]

I believe the argument to optional should be typing.Optional[str] instead of str. Any thoughts on this?

I would love to contribute a PR, if you agree.

Thanks!

sobolevn commented 11 months ago

I would love to contribute a PR, if you agree.

Please :)