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

IsADirectoryError with condition in optional include #545

Closed SukiCZ closed 3 months ago

SukiCZ commented 3 months ago

I have a settings like this

from os import environ

from split_settings.tools import optional, include

ENV = environ.get('ENV', 'local')

include(
    'components/base.py',
    'components/database.py',
    optional('local_settings.py' if ENV == 'local' else None),
)

When I try to run my django app I get an error

  File "/app/config/settings/__init__.py", line 55, in <module>
    include(
  File "/usr/local/lib/python3.11/site-packages/split_settings/tools.py", line 107, in include
    with open(included_file, 'rb') as to_compile:
         ^^^^^^^^^^^^^^^^^^^^^^^^^
IsADirectoryError: [Errno 21] Is a directory: '/app/config/settings'

I tried to fix this error in #510 but the PR is just being ignored. We can't upgrade django-split-settings from version 1.2.0 to newer

sobolevn commented 3 months ago

Oh, I undertand the problem now.