File: 3.x-release-notes.md

package info (click to toggle)
python-dynaconf 3.1.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,116 kB
  • sloc: python: 12,959; makefile: 4
file content (151 lines) | stat: -rw-r--r-- 5,229 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Dynaconf 3.0.0

In Dynaconf 3.0.0 we introduced some improvements and with
those improvements it comes some **breaking changes.**

Some of the changes were discussed on the **1st Dynaconf community meeting** [video is available](https://www.twitch.tv/videos/657033043) and [meeting notes #354](https://github.com/rochacbruno/dynaconf/issues/354).


## Improvements

- Validators now implements `|` and `&` operators to allow `Validator() &| Validator()` and has more `operations` available such as `len_eq, len_min, len_max, startswith` [#353](https://github.com/rochacbruno/dynaconf/pull/353).
- First level variables are now allowed to be `lowercase` it is now possible to access `settings.foo` or `settings.FOO` [#357](https://github.com/rochacbruno/dynaconf/pull/357).
- All Dependencies are now vendored, so when installing Dynaconf is not needed to install any dependency.
- Dynaconf configuration options are now aliased so when creating an instance of `LazySettings|FlaskDynaconf|DjangoDynaconf` it is now possible to pass instead of `ENVVAR_PREFIX_FOR_DYNACONF` just `envvar_prefix` and this lowercase alias is now accepted.
- Fixed bugs in `merge` and deprecated the `@reset` token.
- Added implementation for `__dir__` to allow auto complete for terminal and IDEs.
- Add option to override mount point for vault server.
- `LazySettings` is now aliased to `Dynaconf`
- `Dynaconf` class now accepts a parameter `validators=[Validator, ...]` that will be immediately evaluated when passed.

## Breaking Changes

> **NOTE 1** `from dynaconf import settings` will keep working until version `4.0.x` to allow users to migrate gradually without having breaking changes but it will raise some DeprecationWarnings.


> **NOTE 2** If you are using `FLASK` or `DJANGO` plugins there will be no breaking change on the framework settings, **a.k.a your project will keep working fine!**.


#### `dynaconf.settings` global settings instance is now deprecated.

Users are now supposed to create their own instance of `settings` instead of using the deprecated `from dynaconf import settings`.

**project/config.py**
```python
from dynaconf import Dynaconf

settings = Dynaconf(**options)
```

and then in your program you do `from project.config import settings` instead of `from dynaconf import settings`.

The `**options` are any of the [dynaconf config options](https://dynaconf.readthedocs.io/en/latest/guides/configuration.html)

ex:

```python
settings = Dynaconf(
    settings_file=["settings.toml", ".secrets.toml"],
    envvar_prefix="MYPROJECT"
)
```

> With the above instance your `settings` will load data from those 2 `.toml` files and also environment variables prefixed with `MYPROOJECT` e.g: `export MYPROJECT_FOO=1`


#### Dynaconf is now envless by default.

Historically Dynaconf worked in a multi layered environments for
loading data from files, so you were supposed to have a file like:

```toml
[default]
key = 'value'

[production]
key = 'value'
```

**Now starting on 3.0.0** the environments are disabled by default, so the same file can be crated as.

```toml
key = 'value'
```

And you can still have the environments but only if you explicit specify it when creating your instance.


To have the previous behavior supporting all environments from the first level of a file.

```python
settings = Dynaconf(
    environments=True
)
```

or to strictly specify your environments.

```python
settings = Dynaconf(
    environments=["default", "prodution", "testing", "xyz"],
)
```

Once it is defined all the other functionalities still works such as.

```bash
export ENV_FOR_DYNACONF=production myprogram.py
```

#### Automatic load of `settings.*` files are disabled by default.

Starting on 3.x Dynaconf will now only load files passed explicitly to **settings_file** option when creating the instance or specified as env var **SETTINGS_FILE_FOR_DYNACONF**.

When creating the settings instance the file **paths** or **globs** should be specified unless you want only env vars and external loaders to be loaded.

Single file


```py
settings = Dynaconf(
    settings_file="settings.toml",
)
```

Or multiple files.


```py
settings = Dynaconf(
    settings_file=["settings.toml", "path/*.yaml"],
)
```

Dynaconf will respect the exact order informed by you on the `settings_file` parameter.

> **NOTE** the parameters `preload`, `includes` and `secret` continues to work in the same way as before.
> **NOTE** the parameters `preload`, `includes` and `secret` continues to work in the same way as before.

#### Load of dotenv `.env` is now disabled by default.

Dynaconf will **NO MORE** automatically load the data from `.env` file and will do that only
if `load_dotenv=True` is provided.


```py
settings = Dynaconf(
    load_dotenv=True
)
```

BY default it keeps searching for files in the current `PROJECT_ROOT` named `.env` and the `dotenv_path` accepts a relative path such as `.env` or  `path/to/.env`

#### DEBUG Logging is now completely removed

There is no more `logging` or `debug` messages being printed, so the variable `DEBUG_LEVEL` has no more effect.


## Coming in 3.1.x

- Support for Pydantic BaseSettings for Validators.
- Support for replacement of `toml` parser on envvars loader.