poetry-plugin-dotenv 3.2.0__tar.gz → 3.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (17) hide show
  1. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/PKG-INFO +8 -62
  2. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/README.md +7 -61
  3. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/pyproject.toml +20 -76
  4. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/__init__.py +3 -1
  5. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/configurator.py +34 -8
  6. poetry_plugin_dotenv-3.3.2/src/poetry_plugin_dotenv/loader.py +54 -0
  7. poetry_plugin_dotenv-3.2.0/src/poetry_plugin_dotenv/loader.py +0 -45
  8. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/LICENSE +0 -0
  9. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/commands.py +0 -0
  10. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/dotenv/__init__.py +0 -0
  11. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/dotenv/core.py +0 -0
  12. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/dotenv/parsers.py +0 -0
  13. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/dotenv/variables.py +0 -0
  14. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/exceptions.py +0 -0
  15. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/logging.py +0 -0
  16. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/plugin.py +0 -0
  17. {poetry_plugin_dotenv-3.2.0 → poetry_plugin_dotenv-3.3.2}/src/poetry_plugin_dotenv/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: poetry-plugin-dotenv
3
- Version: 3.2.0
3
+ Version: 3.3.2
4
4
  Summary: poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -38,83 +38,29 @@ Project-URL: Repository, https://github.com/pivoshenko/poetry-plugin-dotenv
38
38
  Project-URL: Releases, https://github.com/pivoshenko/poetry-plugin-dotenv/releases
39
39
  Description-Content-Type: text/markdown
40
40
 
41
- <div align="center">
42
- <img alt="logo" src="https://github.com/pivoshenko/poetry-plugin-dotenv/blob/main/docs/assets/logo.svg?raw=True" height=200>
43
- </div>
44
-
45
- <br>
41
+ <h1 align="left">
42
+ <img src="docs/assets/logo.svg" alt="" height="40" align="left" style="vertical-align: middle; margin-right: 12px;">
43
+ poetry-plugin-dotenv
44
+ </h1>
46
45
 
47
- <p align="center">
48
- <a href="https://opensource.org/licenses/MIT">
49
- <img alt="License" src="https://img.shields.io/pypi/l/poetry-plugin-dotenv?style=flat-square&logo=opensourceinitiative&logoColor=white&color=0A6847&label=License">
50
- </a>
46
+ <p align="left">
51
47
  <a href="https://pypi.org/project/poetry-plugin-dotenv">
52
48
  <img alt="Python" src="https://img.shields.io/pypi/pyversions/poetry-plugin-dotenv?style=flat-square&logo=python&logoColor=white&color=4856CD&label=Python">
53
49
  </a>
54
50
  <a href="https://pypi.org/project/poetry-plugin-dotenv">
55
51
  <img alt="PyPI" src="https://img.shields.io/pypi/v/poetry-plugin-dotenv?style=flat-square&logo=pypi&logoColor=white&color=4856CD&label=PyPI">
56
52
  </a>
57
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/releases">
58
- <img alt="Release" src="https://img.shields.io/github/v/release/pivoshenko/poetry-plugin-dotenv?style=flat-square&logo=github&logoColor=white&color=4856CD&label=Release">
59
- </a>
60
- </p>
61
-
62
- <p align="center">
63
- <a href="https://semantic-release.gitbook.io">
64
- <img alt="Semantic_Release" src="https://img.shields.io/badge/Semantic_Release-angular-e10079?style=flat-square&logo=semanticrelease&logoColor=white&color=D83A56">
65
- </a>
66
- <a href="https://pycqa.github.io/isort">
67
- <img alt="Imports" src="https://img.shields.io/badge/Imports-isort-black.svg?style=flat-square&logo=improvmx&logoColor=white&color=637A9F&">
53
+ <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/ci.yaml">
54
+ <img alt="CI" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/ci.yaml?label=CI&style=flat-square&logo=githubactions&logoColor=white&color=0A6847">
68
55
  </a>
69
56
  <a href="https://docs.astral.sh/ruff">
70
57
  <img alt="Ruff" src="https://img.shields.io/badge/Style-ruff-black.svg?style=flat-square&logo=ruff&logoColor=white&color=D7FF64">
71
58
  </a>
72
- <a href="https://mypy.readthedocs.io/en/stable/index.html">
73
- <img alt="mypy" src="https://img.shields.io/badge/mypy-checked-success.svg?style=flat-square&logo=pypy&logoColor=white&color=0A6847">
74
- </a>
75
- </p>
76
-
77
- <p align="center">
78
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/tests.yaml">
79
- <img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/tests.yaml?label=Tests&style=flat-square&logo=pytest&logoColor=white&color=0A6847">
80
- </a>
81
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/linters.yaml">
82
- <img alt="Linters" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/linters.yaml?label=Linters&style=flat-square&logo=lintcode&logoColor=white&color=0A6847">
83
- </a>
84
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/release.yaml">
85
- <img alt="Release" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/release.yaml?label=Release&style=flat-square&logo=pypi&logoColor=white&color=0A6847">
86
- </a>
87
- <a href="https://codecov.io/gh/pivoshenko/poetry-plugin-dotenv" >
88
- <img alt="Codecov" src="https://img.shields.io/codecov/c/gh/pivoshenko/poetry-plugin-dotenv?token=cqRQxVnDR6&style=flat-square&logo=codecov&logoColor=white&color=0A6847&label=Coverage"/>
89
- </a>
90
- </p>
91
-
92
- <p align="center">
93
- <a href="https://pypi.org/project/poetry-plugin-dotenv">
94
- <img alt="Downloads" src="https://img.shields.io/pypi/dm/poetry-plugin-dotenv?style=flat-square&logo=pythonanywhere&logoColor=white&color=4856CD&label=Downloads">
95
- </a>
96
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv">
97
- <img alt="Stars" src="https://img.shields.io/github/stars/pivoshenko/poetry-plugin-dotenv?style=flat-square&logo=apachespark&logoColor=white&color=4856CD&label=Stars">
98
- </a>
99
- </p>
100
-
101
- <p align="center">
102
59
  <a href="https://stand-with-ukraine.pp.ua">
103
60
  <img alt="StandWithUkraine" src="https://img.shields.io/badge/Support-Ukraine-FFC93C?style=flat-square&labelColor=07689F">
104
61
  </a>
105
62
  </p>
106
63
 
107
- - [Overview](#overview)
108
- - [Features](#features)
109
- - [Installation](#installation)
110
- - [Usage and Configuration](#usage-and-configuration)
111
- - [`ignore`](#ignore)
112
- - [`location`](#location)
113
- - [Configuration via TOML file](#configuration-via-toml-file)
114
- - [Configuration via environment variables](#configuration-via-environment-variables)
115
- - [Lookup hierarchy](#lookup-hierarchy)
116
- - [Examples](#examples)
117
-
118
64
  ## Overview
119
65
 
120
66
  `poetry-plugin-dotenv` - is the plugin that automatically loads environment variables from a dotenv file into the environment before `poetry` commands are run.
@@ -1,80 +1,26 @@
1
- <div align="center">
2
- <img alt="logo" src="https://github.com/pivoshenko/poetry-plugin-dotenv/blob/main/docs/assets/logo.svg?raw=True" height=200>
3
- </div>
4
-
5
- <br>
1
+ <h1 align="left">
2
+ <img src="docs/assets/logo.svg" alt="" height="40" align="left" style="vertical-align: middle; margin-right: 12px;">
3
+ poetry-plugin-dotenv
4
+ </h1>
6
5
 
7
- <p align="center">
8
- <a href="https://opensource.org/licenses/MIT">
9
- <img alt="License" src="https://img.shields.io/pypi/l/poetry-plugin-dotenv?style=flat-square&logo=opensourceinitiative&logoColor=white&color=0A6847&label=License">
10
- </a>
6
+ <p align="left">
11
7
  <a href="https://pypi.org/project/poetry-plugin-dotenv">
12
8
  <img alt="Python" src="https://img.shields.io/pypi/pyversions/poetry-plugin-dotenv?style=flat-square&logo=python&logoColor=white&color=4856CD&label=Python">
13
9
  </a>
14
10
  <a href="https://pypi.org/project/poetry-plugin-dotenv">
15
11
  <img alt="PyPI" src="https://img.shields.io/pypi/v/poetry-plugin-dotenv?style=flat-square&logo=pypi&logoColor=white&color=4856CD&label=PyPI">
16
12
  </a>
17
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/releases">
18
- <img alt="Release" src="https://img.shields.io/github/v/release/pivoshenko/poetry-plugin-dotenv?style=flat-square&logo=github&logoColor=white&color=4856CD&label=Release">
19
- </a>
20
- </p>
21
-
22
- <p align="center">
23
- <a href="https://semantic-release.gitbook.io">
24
- <img alt="Semantic_Release" src="https://img.shields.io/badge/Semantic_Release-angular-e10079?style=flat-square&logo=semanticrelease&logoColor=white&color=D83A56">
25
- </a>
26
- <a href="https://pycqa.github.io/isort">
27
- <img alt="Imports" src="https://img.shields.io/badge/Imports-isort-black.svg?style=flat-square&logo=improvmx&logoColor=white&color=637A9F&">
13
+ <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/ci.yaml">
14
+ <img alt="CI" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/ci.yaml?label=CI&style=flat-square&logo=githubactions&logoColor=white&color=0A6847">
28
15
  </a>
29
16
  <a href="https://docs.astral.sh/ruff">
30
17
  <img alt="Ruff" src="https://img.shields.io/badge/Style-ruff-black.svg?style=flat-square&logo=ruff&logoColor=white&color=D7FF64">
31
18
  </a>
32
- <a href="https://mypy.readthedocs.io/en/stable/index.html">
33
- <img alt="mypy" src="https://img.shields.io/badge/mypy-checked-success.svg?style=flat-square&logo=pypy&logoColor=white&color=0A6847">
34
- </a>
35
- </p>
36
-
37
- <p align="center">
38
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/tests.yaml">
39
- <img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/tests.yaml?label=Tests&style=flat-square&logo=pytest&logoColor=white&color=0A6847">
40
- </a>
41
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/linters.yaml">
42
- <img alt="Linters" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/linters.yaml?label=Linters&style=flat-square&logo=lintcode&logoColor=white&color=0A6847">
43
- </a>
44
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/release.yaml">
45
- <img alt="Release" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/release.yaml?label=Release&style=flat-square&logo=pypi&logoColor=white&color=0A6847">
46
- </a>
47
- <a href="https://codecov.io/gh/pivoshenko/poetry-plugin-dotenv" >
48
- <img alt="Codecov" src="https://img.shields.io/codecov/c/gh/pivoshenko/poetry-plugin-dotenv?token=cqRQxVnDR6&style=flat-square&logo=codecov&logoColor=white&color=0A6847&label=Coverage"/>
49
- </a>
50
- </p>
51
-
52
- <p align="center">
53
- <a href="https://pypi.org/project/poetry-plugin-dotenv">
54
- <img alt="Downloads" src="https://img.shields.io/pypi/dm/poetry-plugin-dotenv?style=flat-square&logo=pythonanywhere&logoColor=white&color=4856CD&label=Downloads">
55
- </a>
56
- <a href="https://github.com/pivoshenko/poetry-plugin-dotenv">
57
- <img alt="Stars" src="https://img.shields.io/github/stars/pivoshenko/poetry-plugin-dotenv?style=flat-square&logo=apachespark&logoColor=white&color=4856CD&label=Stars">
58
- </a>
59
- </p>
60
-
61
- <p align="center">
62
19
  <a href="https://stand-with-ukraine.pp.ua">
63
20
  <img alt="StandWithUkraine" src="https://img.shields.io/badge/Support-Ukraine-FFC93C?style=flat-square&labelColor=07689F">
64
21
  </a>
65
22
  </p>
66
23
 
67
- - [Overview](#overview)
68
- - [Features](#features)
69
- - [Installation](#installation)
70
- - [Usage and Configuration](#usage-and-configuration)
71
- - [`ignore`](#ignore)
72
- - [`location`](#location)
73
- - [Configuration via TOML file](#configuration-via-toml-file)
74
- - [Configuration via environment variables](#configuration-via-environment-variables)
75
- - [Lookup hierarchy](#lookup-hierarchy)
76
- - [Examples](#examples)
77
-
78
24
  ## Overview
79
25
 
80
26
  `poetry-plugin-dotenv` - is the plugin that automatically loads environment variables from a dotenv file into the environment before `poetry` commands are run.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "poetry-plugin-dotenv"
3
- version = "3.2.0"
3
+ version = "3.3.2"
4
4
  description = "poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run."
5
5
  license = "MIT"
6
6
  authors = ["Volodymyr Pivoshenko <contact@pivoshenko.dev>"]
@@ -54,62 +54,49 @@ packages = [{ include = "poetry_plugin_dotenv", from = "src" }]
54
54
 
55
55
  [tool.poetry.dependencies]
56
56
  poetry = ">=1.5.0,<3.0.0"
57
- python = ">=3.9,<4.0"
58
-
59
- [tool.poetry.group.ci.dependencies]
60
- python-semantic-release = "^10.5.3"
61
-
62
- [tool.poetry.group.dev.dependencies]
63
- ipdb = "^0.13.13"
64
- ipython = "^8.12.3"
65
- poethepoet = "^0.37.0"
57
+ python = "~=3.9,<4.0"
66
58
 
67
59
  [tool.poetry.group.formatters.dependencies]
68
- pyupgrade = "^3.21.0"
69
- ruff = "^0.15.4"
60
+ pyupgrade = "~=3.21.0"
61
+ ruff = "~=0.15.8"
70
62
 
71
63
  [tool.poetry.group.linters.dependencies]
72
- commitizen = "^4.10.1"
73
- ruff = "^0.15.4"
74
- ty = ">=0.0.17,<0.0.20"
64
+ ruff = "~=0.15.8"
65
+ ty = "~=0.0.17,<0.0.24"
75
66
 
76
67
  [tool.poetry.group.tests.dependencies]
77
- coverage = { version = "^7.10.7", extras = ["toml"] }
78
- pytest = "7.4.4"
79
- pytest-cov = "^7.0.0"
80
- pytest-lazy-fixture = "^0.6.3"
81
- pytest-mock = "^3.15.1"
82
- pytest-sugar = "^1.1.1"
83
- sh = "^2.2.2"
84
- xdoctest = "^1.3.0"
68
+ coverage = { version = "~=7.10.7", extras = ["toml"] }
69
+ pytest = "~=7.4.4"
70
+ pytest-cov = "~=7.1.0"
71
+ pytest-mock = "~=3.15.1"
72
+ pytest-sugar = "~=1.1.1"
85
73
 
86
74
  [tool.poetry.plugins."poetry.application.plugin"]
87
75
  poetry-plugin-dotenv = "poetry_plugin_dotenv.plugin:DotenvPlugin"
88
76
 
89
77
  [build-system]
90
78
  build-backend = "poetry.core.masonry.api"
91
- requires = ["poetry-core>=1.0.0"]
92
-
93
- [tool.codespell]
94
- ignore-words-list = ["redunant", "resovle", "socio-economic"]
95
- skip = ["poetry.lock"]
96
-
97
- [tool.commitizen]
98
- allowed_prefixes = ["0", "1", "2", "3", "Initial", "Merge", "build", "tests"]
79
+ requires = ["poetry-core>=1.0.0,<3.0.0"]
99
80
 
100
81
  [tool.coverage.run]
101
82
  omit = ["*/__init__.py"]
102
83
 
103
84
  [tool.pytest.ini_options]
104
- addopts = ["--basetemp=tests/fixtures", "--color=yes", "--cov=src", "--cov-report=xml", "--cov-report=html", "--xdoc"]
85
+ addopts = ["--basetemp=tests/fixtures", "--color=yes", "--cov=src", "--cov-report=term-missing"]
105
86
  testpaths = ["tests"]
106
87
 
88
+ [tool.ty.environment]
89
+ python-version = "3.10"
90
+
107
91
  [tool.ruff]
108
92
  fix = true
109
93
  line-length = 100
110
- target-version = "py313"
111
94
  unsafe-fixes = true
112
95
 
96
+ [tool.ruff.format]
97
+ docstring-code-format = true
98
+ quote-style = "double"
99
+
113
100
  [tool.ruff.lint]
114
101
  ignore = ["D107", "D102", "D103", "D203", "D213", "COM812"]
115
102
  select = ["ALL"]
@@ -128,46 +115,3 @@ required-imports = ["from __future__ import annotations"]
128
115
  "src/poetry_plugin_dotenv/plugin.py" = ["ARG002", "ANN002", "ANN003"]
129
116
  "src/poetry_plugin_dotenv/dotenv/variables.py" = ["ARG002", "ANN002", "ANN003"]
130
117
  "tests/*.*" = ["INP001", "S101"]
131
-
132
- [tool.ruff.format]
133
- docstring-code-format = true
134
- quote-style = "double"
135
-
136
- [tool.semantic_release]
137
- changelog_file = "CHANGELOG.md"
138
- commit_author = "github-actions <github-actions@github.com>"
139
- exclude_commit_patterns = ["Merge pull request"]
140
- logging_use_named_masks = true
141
- version_toml = ["pyproject.toml:tool.poetry.version"]
142
- version_variables = ["src/poetry_plugin_dotenv/__init__.py:__version__"]
143
-
144
- [tool.semantic_release.changelog]
145
- exclude_commit_patterns = ['''Merged? .*''', '''Initial Commit.*''', '''^\d+\.\d+\.\d+''']
146
-
147
- [tool.semantic_release.commit_parser_options]
148
- major_tags = ["feat"]
149
- minor_tags = ["fix", "perf", "refactor"]
150
- patch_tags = ["docs", "style"]
151
-
152
- [tool.poe]
153
- poetry_command = ""
154
-
155
- [tool.poe.tasks.format]
156
- help = "Run formatters"
157
- sequence = [
158
- { shell = "find src -type f -name '*.py' | xargs poetry run pyupgrade --py39-plus", help = "Run annotations formatter" },
159
- { shell = "find tests -type f -name '*.py' | xargs poetry run pyupgrade --py39-plus", help = "Run annotations formatter" },
160
- { shell = "poetry run ruff format .", help = "Run code formatter" }
161
- ]
162
-
163
- [tool.poe.tasks.lint]
164
- help = "Run linters"
165
- sequence = [
166
- { shell = "poetry run ty check .", help = "Run types linter" },
167
- { shell = "poetry run ruff check .", help = "Run code linter" },
168
- { shell = "poetry run cz check --rev-range .", help = "Run commits linter" }
169
- ]
170
-
171
- [tool.poe.tasks.tests]
172
- help = "Run tests"
173
- shell = "poetry run pytest ."
@@ -2,12 +2,14 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from importlib.metadata import version
6
+
5
7
 
6
8
  __title__ = "poetry-plugin-dotenv"
7
9
  __summary__ = "poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run."
8
10
  __uri__ = "https://github.com/pivoshenko/poetry-plugin-dotenv"
9
11
 
10
- __version__ = "3.2.0"
12
+ __version__ = version("poetry-plugin-dotenv")
11
13
 
12
14
  __author__ = "Volodymyr Pivoshenko"
13
15
  __email__ = "contact@pivoshenko.dev"
@@ -6,6 +6,9 @@ import os
6
6
  import pathlib
7
7
  import dataclasses
8
8
 
9
+ from typing import TYPE_CHECKING
10
+ from typing import Any
11
+
9
12
  import tomlkit
10
13
 
11
14
 
@@ -36,7 +39,13 @@ class _Config:
36
39
  """Defines the schema and default values for the plugin configuration."""
37
40
 
38
41
  ignore: bool = False
39
- location: pathlib.Path = pathlib.Path()
42
+ location: list[pathlib.Path] = dataclasses.field(default_factory=list)
43
+
44
+
45
+ if TYPE_CHECKING:
46
+ ConfigValue = str | bool | list[str] | list[pathlib.Path] | pathlib.Path | None
47
+ else:
48
+ ConfigValue = Any
40
49
 
41
50
 
42
51
  class Config(_Config):
@@ -45,7 +54,7 @@ class Config(_Config):
45
54
  def __init__(self, working_dir: pathlib.Path) -> None:
46
55
  super().__init__()
47
56
 
48
- source_config = {}
57
+ source_config: dict[str, ConfigValue] = {}
49
58
  for config_source, section in CONFIG_SOURCES:
50
59
  if config_source.endswith(".toml"):
51
60
  config = _load_config_from_toml(working_dir / config_source, section)
@@ -60,10 +69,10 @@ class Config(_Config):
60
69
 
61
70
  self._apply_source_config(source_config)
62
71
 
63
- def _apply_source_config(self, source_config: dict[str, str | bool | None]) -> None:
72
+ def _apply_source_config(self, source_config: dict[str, ConfigValue]) -> None:
64
73
  """Apply the loaded configuration to the instance variables."""
65
74
  for field in self.__dataclass_fields__.values():
66
- source_value: str | bool | pathlib.Path | None = source_config.get(field.name)
75
+ source_value: ConfigValue = source_config.get(field.name)
67
76
 
68
77
  if (
69
78
  isinstance(field.default, bool)
@@ -72,14 +81,17 @@ class Config(_Config):
72
81
  and isinstance(source_value, str)
73
82
  ):
74
83
  source_value = _as_bool(source_value)
75
- elif field.name == "location" and source_value and isinstance(source_value, str):
76
- source_value = pathlib.Path(source_value)
84
+ elif field.name == "location" and source_value and not isinstance(source_value, bool):
85
+ if isinstance(source_value, pathlib.Path):
86
+ source_value = [source_value]
87
+ else:
88
+ source_value = _as_paths(source_value)
77
89
 
78
90
  if source_value is not None:
79
91
  setattr(self, field.name, source_value)
80
92
 
81
93
 
82
- def _load_config_from_toml(filepath: pathlib.Path, section: str) -> dict[str, str | bool | None]:
94
+ def _load_config_from_toml(filepath: pathlib.Path, section: str) -> dict[str, ConfigValue]:
83
95
  if not filepath.exists():
84
96
  return {}
85
97
 
@@ -92,7 +104,7 @@ def _load_config_from_toml(filepath: pathlib.Path, section: str) -> dict[str, st
92
104
  return config if isinstance(config, dict) else {}
93
105
 
94
106
 
95
- def _load_config_from_os(section: str) -> dict[str, str | bool | None]:
107
+ def _load_config_from_os(section: str) -> dict[str, ConfigValue]:
96
108
  return {
97
109
  key[len(section) :].lower(): value
98
110
  for key, value in os.environ.items()
@@ -100,6 +112,20 @@ def _load_config_from_os(section: str) -> dict[str, str | bool | None]:
100
112
  }
101
113
 
102
114
 
115
+ def _as_paths(value: str | list[str] | list[pathlib.Path]) -> list[pathlib.Path]:
116
+ if isinstance(value, str):
117
+ return [pathlib.Path(path.strip()) for path in value.split(",") if path.strip()]
118
+
119
+ paths: list[pathlib.Path] = []
120
+ for path in value:
121
+ if isinstance(path, pathlib.Path):
122
+ paths.append(path)
123
+ elif path.strip():
124
+ paths.append(pathlib.Path(path.strip()))
125
+
126
+ return paths
127
+
128
+
103
129
  def _as_bool(value: str) -> bool:
104
130
  """Convert a string value to its Boolean equivalent.
105
131
 
@@ -0,0 +1,54 @@
1
+ """Module that contains core loading functionality."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ from poetry_plugin_dotenv import dotenv
8
+
9
+
10
+ if typing.TYPE_CHECKING: # pragma: no cover
11
+ import pathlib
12
+
13
+ from poetry_plugin_dotenv import configurator
14
+ from poetry_plugin_dotenv import logging
15
+
16
+
17
+ def load(logger: logging.Logger, config: configurator.Config, working_dir: pathlib.Path) -> None:
18
+ filepaths = _determine_filepaths(config, working_dir)
19
+
20
+ if config.ignore:
21
+ logger.warning("Not loading environment variables. Ignored by configuration")
22
+ return
23
+
24
+ if not filepaths:
25
+ logger.warning("Not loading environment variables. No valid dotenv filepaths")
26
+ return
27
+
28
+ for filepath in filepaths:
29
+ if filepath.is_file():
30
+ logger.info(f"Loading environment variables: <fg=green>{filepath}</>") # noqa: G004
31
+ dotenv.core.load(filepath=filepath)
32
+ else:
33
+ logger.error(
34
+ f"Could not load environment variables. The file does not exist: {filepath}" # noqa: G004
35
+ )
36
+
37
+
38
+ def _determine_filepaths(
39
+ config: configurator.Config,
40
+ working_dir: pathlib.Path,
41
+ ) -> list[pathlib.Path]:
42
+ if config.location:
43
+ filepaths: list[pathlib.Path] = []
44
+
45
+ for location_path in config.location:
46
+ if location_path.is_absolute():
47
+ filepaths.append(location_path.resolve())
48
+ else:
49
+ filepaths.append(working_dir / location_path)
50
+
51
+ return filepaths
52
+
53
+ filepath = dotenv.core.find(usecwd=True)
54
+ return [filepath] if filepath else []
@@ -1,45 +0,0 @@
1
- """Module that contains core loading functionality."""
2
-
3
- from __future__ import annotations
4
-
5
- import typing
6
- import pathlib
7
-
8
- from poetry_plugin_dotenv import dotenv
9
-
10
-
11
- if typing.TYPE_CHECKING: # pragma: no cover
12
- from poetry_plugin_dotenv import configurator
13
- from poetry_plugin_dotenv import logging
14
-
15
-
16
- def load(logger: logging.Logger, config: configurator.Config, working_dir: pathlib.Path) -> None:
17
- filepath = _determine_filepath(config, working_dir)
18
-
19
- if config.ignore:
20
- logger.warning("Not loading environment variables. Ignored by configuration")
21
- return
22
-
23
- if not filepath:
24
- logger.warning("Not loading environment variables. No valid filepath")
25
- return
26
-
27
- if filepath.is_file():
28
- logger.info(f"Loading environment variables: <fg=green>{filepath}</>") # noqa: G004
29
- dotenv.core.load(filepath=filepath)
30
- else:
31
- logger.error(f"Could not load environment variables. The file does not exist: {filepath}") # noqa: G004
32
-
33
-
34
- def _determine_filepath(
35
- config: configurator.Config,
36
- working_dir: pathlib.Path,
37
- ) -> pathlib.Path | None:
38
- if config.location and config.location != pathlib.Path():
39
- location_path = config.location
40
- if location_path.is_absolute():
41
- return location_path.resolve()
42
-
43
- return working_dir / location_path
44
-
45
- return dotenv.core.find(usecwd=True)