Repository: dynaconf/dynaconf

Issue:
[bug] Attributes not loaded when using setenv and format
**Bug Description**
 I first set the environment to 'development' using the `settings.setenv()` method. Then I tried to access the 'DB_PATH' using the `@format` token in order to use the 'DB_NAME' as shown in the example codes. But, I am getting the `AttributeError: 'Settings' object has no attribute 'DB_NAME'`.

**To Reproduce**
Steps to reproduce the behavior:

1. Having the following folder structure

<!-- Describe or use the command `$ tree -v` and paste below -->

<details>
<summary> Project structure </summary>

```bash

.
│
├── configs/
│   ├── .secrets.toml
│   └── settings.toml
│
├── my_package/
│   └── my_program.py
│
└── config.py

```
</details>

2. Having the following config files:

<!-- Please adjust if you are using different files and formats! -->

<details>
<summary> Config files </summary>

**./configs/settings.toml**
```toml
[default]
DB_NAME = "mydb.db"

[development]
DB_PATH = "@format {env[HOME]}/{this.current_env}/{this.DB_NAME}"
```

</details>

3. Having the following app code:

<details>
<summary> Code </summary>

**./my_package/my_program.py**
```python
import click

from config import settings


@click.group()
@click.option("--config", default="default")
def main(config):
    click.echo(f"Environment: {config}")
    settings.setenv(config)
    return


@main.command()
def dynaconf():
    click.echo(f"Database Path: {settings.DB_PATH}")
    return


if __name__ == "__main__":
    main()
```

**./config.py**
```python
from dynaconf import Dynaconf

settings = Dynaconf(
    envvar_prefix="DYNACONF",
    settings_files=["configs/settings.toml", "configs/.secrets.toml"],
    environments=True,
)
```

</details>

4. Executing under the following environment

<details>
<summary> Execution </summary>

```bash
# virtualenv: poetry

$ python -m my_package.my_program --config development dynaconf
```

</details>

**Expected behavior**
Expected DB_PATH to be set to `$HOME/development/mydb.db`.

**Environment:**
 - OS: Linux/Ubuntu 18.04.5 LTS
 - Dynaconf Version: 3.1.1

**Additional context**
I can access DB_PATH just fine if I don't use the 'setenv' method or make use of the `@jinja` token.



Discussion:

Resolving patch:
diff --git a/dynaconf/base.py b/dynaconf/base.py
--- a/dynaconf/base.py
+++ b/dynaconf/base.py
@@ -724,8 +724,11 @@ def unset(self, key, force=False):
             and key not in self._defaults
             or force
         ):
-            delattr(self, key)
-            self.store.pop(key, None)
+            with suppress(KeyError, AttributeError):
+                # AttributeError can happen when a LazyValue consumes
+                # a previously deleted key
+                delattr(self, key)
+                del self.store[key]
 
     def unset_all(self, keys, force=False):  # pragma: no cover
         """Unset based on a list of keys
diff --git a/example/issues/434_setenv/app.py b/example/issues/434_setenv/app.py
new file mode 100644
--- /dev/null
+++ b/example/issues/434_setenv/app.py
@@ -0,0 +1,28 @@
+import click
+
+from dynaconf import Dynaconf
+
+settings = Dynaconf(
+    envvar_prefix="DYNACONF",
+    settings_files=["settings.toml", ".secrets.toml"],
+    environments=True,
+)
+
+
+@click.group()
+@click.option("--config", default="default")
+def main(config):
+    click.echo(f"Environment: {config}")
+    settings.setenv(config)
+    return
+
+
+@main.command()
+def dynaconf():
+    click.echo(f"Database Path: {settings.DB_PATH}")
+    assert "/mydb.db" in settings.DB_PATH
+    return
+
+
+if __name__ == "__main__":
+    main()
diff --git a/example/issues/434_setenv/config.py b/example/issues/434_setenv/config.py
new file mode 100644
--- /dev/null
+++ b/example/issues/434_setenv/config.py
@@ -0,0 +1,7 @@
+from dynaconf import Dynaconf
+
+settings = Dynaconf(
+    envvar_prefix="DYNACONF",
+    settings_files=["configs/settings.toml", "configs/.secrets.toml"],
+    environments=True,
+)


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -163,6 +163,11 @@ def test_list_with_key():
     assert "TEST_KEY<str> 'test_value'" in result
 
 
+def test_list_with_invalid_key():
+    result = run(["-i", "tests.config.settings", "list", "-k", "TEST_KEY.foo"])
+    assert "Key not found" in result
+
+
 def test_list_with_key_export_json(tmpdir):
     result = run(
         [