Skip to content

[bug] negative numbers not parsed as integers from environment variables #799

@alexgeorgousis

Description

@alexgeorgousis

Describe the bug
In version 1.3.9 environment variables that are negative represented as strings (e.g. DYNACONF_NUM="-1") are not cast to type int when loaded in Python. This isn't true in version 1.3.4.

To Reproduce
Steps to reproduce the behavior:

  1. Having the following folder structure
Project structure
.
├── test.py
└── settings.toml
  1. Having the following config files:
Config files

./settings.toml

num = 1
  1. Having the following app code:
Code

./test.py

from dynaconf import Dynaconf

settings = Dynaconf(settings_file="./settings.toml")
print(settings.num)
print(type(settings.num))
  1. Executing under the following environment
Execution
$ export DYNACONF_NUM="-1"
$ python ./test.py

Expected behavior
The python script should print the following:

-1
<class 'int'>

Actual behavior
The python script prints the following:

-1
<class 'str'>

Environment (please complete the following information):

  • OS: macOS Monerey 12.5.1
  • Dynaconf Version [e.g. 3.1.9]

Additional context
Again, this works as expected in version 3.1.4 so I assume something has changed in a recent version.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions