Repository: dynaconf/dynaconf
Pull request #830 (2022-11-07 18:37:02)

Add Python 3.11 to CI
Thanks @Riverfount

netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *dynaconf* processing.


|  Name | Link |
|---------------------------------|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 586e81a9f1f4b25267afcf955bb077fa738a03ec |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/dynaconf/deploys/636950506f2d6e0008dd7785 |
github-actions[bot]: ## Test Results (Python 3.11)
368 tests   368 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests")  36s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests")
    1 suites      0 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests")
    1 files        0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests")

Results for commit 6ff2192e.

[test-results]:data:application/gzip;base64,H4sIACVSaWMC/13Myw7CIBCF4VdpWLtoB4vgyxgyMMnEXgyXVeO7i6i9uPz+k5xFEA8+imvTnRoRM6cVLgebeJ4KpSouS4oV+qdbzIj/6c6Pkto1kOXhEHwIc/iWkKft843j5adsj9W7w+r9H87jyKlAKCLoDHgCR671YFBpbRDhrGUvbX/xEox0KJ4v796sxgQBAAA=

github-actions[bot]: ## Test Results (Python 3.8)
368 tests  ±0   368 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±0   39s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests") -4s
    1 suites ±0       0 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests") ±0 
    1 files   ±0       0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") ±0 

Results for commit 6ff2192e. ± Comparison against base commit 9f91e0dc.

[test-results]:data:application/gzip;base64,H4sIAClSaWMC/13Myw7CIBCF4VdpWLtoGYvgyxgyMMnEthguK+O7S6v24vL7T3KegnjwSVyb7tSIVDivcCXazGGqBFNdlzxvoPRPt1QQ/9OdHzW1ayDLwyH4GEP8llim7XPG8fJTtsfFu8PF+z8M48i5Qigi2RnpSTpyrZcGldYGUZ419GD7iwdpwKF4vQFHi+1aBAEAAA==

github-actions[bot]: ## Test Results (Python 3.10)
368 tests  ±0   368 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±0   35s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests") -1s
    1 suites ±0       0 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests") ±0 
    1 files   ±0       0 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") ±0 

Results for commit 6ff2192e. ± Comparison against base commit 9f91e0dc.

[test-results]:data:application/gzip;base64,H4sIAClSaWMC/13Myw7CIBCF4VdpWLtoZ6SCL2PIwCTEthguK+O7S6v24vL7T3Kegv3gkrg23akRqfi8wpZosg9TJcrquuR5w179dEuF6D/d/aOmdg1s/HAILsYQvyWWafuccbz8lO1x8e5w8f6Pwjj6XCF6Zug0OAbLtnWgqVdKE8FZoUQjLw5BoyXxegNymwmHBAEAAA==


Patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index d512c15..fe39989 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -36,7 +36,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.8", "3.9", "3.10"]
+        python-version: ["3.8", "3.9", "3.10", "3.11"]
         os: [ubuntu-latest, macos-latest, windows-latest]
     runs-on: ${{ matrix.os }}
     steps:
@@ -61,7 +61,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.8", "3.10"]
+        python-version: ["3.8", "3.10", "3.11"]
         os: [ubuntu-latest]
     runs-on: ${{ matrix.os }}
     steps:
@@ -104,7 +104,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.8", "3.10"]
+        python-version: ["3.8", "3.10", "3.11"]
         os: [macos-latest]
     runs-on: ${{ matrix.os }}
     steps:
@@ -126,7 +126,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.8", "3.10"]
+        python-version: ["3.8", "3.10", "3.11"]
         os: [ubuntu-latest, macos-latest]
     runs-on: ${{ matrix.os }}
     steps:
@@ -146,7 +146,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.8", "3.10"]
+        python-version: ["3.8", "3.10", "3.11"]
         os: [windows-latest]
     runs-on: ${{ matrix.os }}
     steps:
@@ -167,7 +167,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.8", "3.10"]
+        python-version: ["3.8", "3.10", "3.11"]
         os: [windows-latest]
     runs-on: ${{ matrix.os }}
     steps:
@@ -188,7 +188,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.8", "3.10"]
+        python-version: ["3.8", "3.10", "3.11"]
         os: [ubuntu-latest]
     runs-on: ${{ matrix.os }}
     services:
@@ -213,7 +213,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.8", "3.10"]
+        python-version: ["3.8", "3.10", "3.11"]
         os: [ubuntu-latest]
     runs-on: ${{ matrix.os }}
     services:
diff --git a/dynaconf/base.py b/dynaconf/base.py
index 2858b54..15f3df4 100644
--- a/dynaconf/base.py
+++ b/dynaconf/base.py
@@ -753,8 +753,8 @@ class Settings:
         """
         env = env or self.ENV_FOR_DYNACONF
 
-        if not isinstance(env, str):
-            raise AttributeError("env should be a string")
+        if not isinstance(env, str) or "_" in env or " " in env:
+            raise ValueError("env should be a string without _ or spaces")
 
         env = env.upper()
 
diff --git a/setup.py b/setup.py
index af82a87..223653b 100644
--- a/setup.py
+++ b/setup.py
@@ -1,8 +1,6 @@
 from __future__ import annotations
 
-import io
 import os
-import sys
 
 from setuptools import find_packages
 from setuptools import setup
@@ -83,7 +81,7 @@ setup(
         "all": ["redis", "ruamel.yaml", "configobj", "hvac"],
         "test": test_requirements,
     },
-    python_requires=">=3.7",
+    python_requires=">=3.8",
     entry_points={"console_scripts": ["dynaconf=dynaconf.cli:main"]},
     setup_requires=["setuptools>=38.6.0"],
     classifiers=[
@@ -100,6 +98,7 @@ setup(
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
         "Topic :: Utilities",
         "Topic :: Software Development :: Libraries",
         "Topic :: Software Development :: Libraries :: Python Modules",


Test patch:
diff --git a/tests/test_base.py b/tests/test_base.py
index ae1fe9b..18363ba 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -204,15 +204,13 @@ def test_as_json(settings):
 
 
 def test_env_should_be_string(settings):
-    with pytest.raises(AttributeError):
-        with settings.setenv(123456):
-            pass
+    with pytest.raises(ValueError):
+        settings.setenv(123456)
 
 
 def test_env_should_not_have_underline(settings):
-    with pytest.raises(AttributeError):
-        with settings.setenv("COOL_env"):
-            pass
+    with pytest.raises(ValueError):
+        settings.setenv("COOL_env")
 
 
 def test_path_for(settings):