New upstream release.
Debian Janitor
8 months ago
4 | 4 | - package-ecosystem: pip |
5 | 5 | # setup.py stored in repository root. |
6 | 6 | directory: '/' |
7 | # Raise pull requests for version updates | |
8 | # to pip against the `develop` branch | |
9 | target-branch: develop | |
7 | 10 | schedule: |
8 | interval: daily | |
11 | # Check for updates managed by pip once a week | |
12 | interval: weekly | |
13 | # Specify labels for npm pull requests | |
14 | labels: | |
15 | - pip | |
16 | - dependencies | |
9 | 17 | assignees: |
10 | 18 | - sergeyklay |
11 | 19 | |
13 | 21 | # Workflow files stored in the |
14 | 22 | # default location of `.github/workflows` |
15 | 23 | directory: '/' |
24 | # Raise pull requests for version updates | |
25 | # to pip against the `develop` branch | |
26 | target-branch: develop | |
16 | 27 | schedule: |
17 | interval: daily | |
28 | # Check for updates for GitHub actions once a week | |
29 | interval: weekly | |
30 | # Specify labels for npm pull requests | |
31 | labels: | |
32 | - github_actions | |
33 | - dependencies | |
18 | 34 | assignees: |
19 | 35 | - sergeyklay |
1 | 1 | |
2 | 2 | on: |
3 | 3 | push: |
4 | branches: | |
5 | - develop | |
6 | - main | |
7 | - 'feature/**' | |
8 | - 'release/**' | |
9 | - 'fix/**' | |
4 | branches-ignore: | |
5 | # These should always correspond to pull requests, so ignore them for | |
6 | # the push trigger and let them be triggered by the pull_request | |
7 | # trigger, avoiding running the workflow twice. This is a minor | |
8 | # optimization so there's no need to ensure this is comprehensive. | |
9 | - 'dependabot/**' | |
10 | 10 | tags: |
11 | 11 | - 'v[0-9]+.[0-9]+.[0-9]+' |
12 | 12 | |
13 | # The branches below must be a subset of the branches above | |
13 | 14 | pull_request: |
14 | 15 | branches: |
15 | 16 | - develop |
18 | 19 | jobs: |
19 | 20 | build: |
20 | 21 | name: Build and test package distribution |
21 | runs-on: ${{ matrix.os }} | |
22 | ||
23 | strategy: | |
24 | matrix: | |
25 | os: [ ubuntu-latest, macos-latest, windows-latest ] | |
22 | runs-on: ubuntu-latest | |
26 | 23 | |
27 | 24 | steps: |
28 | 25 | - name: Checkout code |
29 | uses: actions/checkout@v3.0.2 | |
26 | uses: actions/checkout@v3.3.0 | |
30 | 27 | |
31 | 28 | - name: Set up Python 3.10 |
32 | uses: actions/setup-python@v4.0.0 | |
29 | uses: actions/setup-python@v4.5.0 | |
33 | 30 | with: |
34 | 31 | python-version: '3.10' |
35 | 32 | |
66 | 63 | |
67 | 64 | steps: |
68 | 65 | - name: Checkout code |
69 | uses: actions/checkout@v3.0.2 | |
66 | uses: actions/checkout@v3.3.0 | |
70 | 67 | |
71 | 68 | - name: Set up Python 3.10 |
72 | uses: actions/setup-python@v4.0.0 | |
69 | uses: actions/setup-python@v4.5.0 | |
73 | 70 | with: |
74 | 71 | python-version: '3.10' |
75 | 72 |
0 | name: Make sure new PRs are sent to develop | |
1 | ||
2 | on: | |
3 | pull_request_target: | |
4 | types: [opened, edited] | |
5 | ||
6 | jobs: | |
7 | check-branch: | |
8 | runs-on: ubuntu-latest | |
9 | steps: | |
10 | - uses: Vankka/pr-target-branch-action@v2 | |
11 | env: | |
12 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
13 | with: | |
14 | target: main | |
15 | exclude: develop # Don't prevent going from develop -> main | |
16 | change-to: develop | |
17 | comment: | | |
18 | Your PR was set to target `main`, PRs should be target `develop` | |
19 | The base branch of this PR has been automatically changed to `develop`, please check that there are no merge conflicts. |
1 | 1 | |
2 | 2 | on: |
3 | 3 | push: |
4 | branches: | |
5 | - develop | |
6 | - main | |
7 | - 'feature/**' | |
8 | - 'release/**' | |
9 | - 'fix/**' | |
4 | branches-ignore: | |
5 | # These should always correspond to pull requests, so ignore them for | |
6 | # the push trigger and let them be triggered by the pull_request | |
7 | # trigger, avoiding running the workflow twice. This is a minor | |
8 | # optimization so there's no need to ensure this is comprehensive. | |
9 | - 'dependabot/**' | |
10 | 10 | |
11 | # The branches below must be a subset of the branches above | |
11 | 12 | pull_request: |
12 | 13 | branches: |
13 | 14 | - develop |
45 | 46 | |
46 | 47 | matrix: |
47 | 48 | python: |
48 | - '3.5' | |
49 | - '3.6' | |
50 | - '3.7' | |
51 | 49 | - '3.8' |
52 | 50 | - '3.9' |
53 | 51 | - '3.10' |
52 | - '3.11' | |
54 | 53 | - 'pypy-3.7' |
55 | 54 | os: [ ubuntu-latest, macos-latest, windows-latest ] |
56 | 55 | |
56 | # These versions are no longer supported by Python team, and may | |
57 | # eventually be dropped from GitHub Actions. The support of these | |
58 | # versions by django-environ will continue for as long as possible, | |
59 | # and may be discontinued at any time. | |
60 | include: | |
61 | - python: '3.5' | |
62 | os: ubuntu-20.04 | |
63 | - python: '3.6' | |
64 | os: ubuntu-20.04 | |
65 | - python: '3.7' | |
66 | os: ubuntu-20.04 | |
67 | ||
57 | 68 | steps: |
58 | 69 | - name: Checkout code |
59 | uses: actions/checkout@v3.0.2 | |
70 | uses: actions/checkout@v3.3.0 | |
60 | 71 | with: |
61 | 72 | fetch-depth: 5 |
62 | 73 | |
63 | 74 | - name: Set up Python ${{ matrix.python }} |
64 | uses: actions/setup-python@v4.0.0 | |
75 | uses: actions/setup-python@v4.5.0 | |
65 | 76 | with: |
66 | 77 | python-version: ${{ matrix.python }} |
67 | 78 |
0 | name: CodeQL | |
1 | ||
2 | on: | |
3 | push: | |
4 | branches: | |
5 | - develop | |
6 | - main | |
7 | ||
8 | # The branches below must be a subset of the branches above | |
9 | pull_request: | |
10 | branches: | |
11 | - develop | |
12 | - main | |
13 | ||
14 | schedule: | |
15 | - cron: '40 22 * * 5' | |
16 | # | | | | | | |
17 | # | | | | |____ day of the week (0 - 6 or SUN-SAT) | |
18 | # | | | |____ month (1 - 12 or JAN-DEC) | |
19 | # | | |____ day of the month (1 - 31) | |
20 | # | |____ hour (0 - 23) | |
21 | # |____ minute (0 - 59) | |
22 | ||
23 | jobs: | |
24 | analyze: | |
25 | name: Analyze | |
26 | runs-on: ubuntu-latest | |
27 | permissions: | |
28 | actions: read | |
29 | contents: read | |
30 | security-events: write | |
31 | ||
32 | # The maximum number of minutes to let a workflow run | |
33 | # before GitHub automatically cancels it. Default: 360 | |
34 | timeout-minutes: 30 | |
35 | ||
36 | strategy: | |
37 | # When set to true, GitHub cancels | |
38 | # all in-progress jobs if any matrix job fails. | |
39 | fail-fast: false | |
40 | ||
41 | matrix: | |
42 | language: | |
43 | - python | |
44 | ||
45 | steps: | |
46 | - name: Checkout repository | |
47 | uses: actions/checkout@v3.3.0 | |
48 | ||
49 | # Initializes the CodeQL tools for scanning. | |
50 | - name: Initialize CodeQL | |
51 | uses: github/codeql-action/init@v2 | |
52 | with: | |
53 | languages: ${{ matrix.language }} | |
54 | ||
55 | - name: Autobuild | |
56 | uses: github/codeql-action/autobuild@v2 | |
57 | ||
58 | - name: Perform CodeQL Analysis | |
59 | uses: github/codeql-action/analyze@v2 |
1 | 1 | |
2 | 2 | on: |
3 | 3 | push: |
4 | branches: | |
5 | - develop | |
6 | - main | |
7 | - 'feature/**' | |
8 | - 'release/**' | |
9 | - 'fix/**' | |
4 | branches-ignore: | |
5 | # These should always correspond to pull requests, so ignore them for | |
6 | # the push trigger and let them be triggered by the pull_request | |
7 | # trigger, avoiding running the workflow twice. This is a minor | |
8 | # optimization so there's no need to ensure this is comprehensive. | |
9 | - 'dependabot/**' | |
10 | 10 | |
11 | 11 | pull_request: |
12 | 12 | branches: |
18 | 18 | runs-on: ubuntu-latest |
19 | 19 | name: Code linting |
20 | 20 | |
21 | # The maximum number of minutes to let a workflow run | |
22 | # before GitHub automatically cancels it. Default: 360 | |
23 | timeout-minutes: 30 | |
24 | ||
21 | 25 | steps: |
22 | 26 | - name: Checkout code |
23 | uses: actions/checkout@v3.0.2 | |
27 | uses: actions/checkout@v3.3.0 | |
24 | 28 | |
25 | 29 | - name: Set up Python 3.10 |
26 | uses: actions/setup-python@v4.0.0 | |
30 | uses: actions/setup-python@v4.5.0 | |
27 | 31 | with: |
28 | 32 | python-version: '3.10' |
29 | 33 |
1 | 1 | |
2 | 2 | on: |
3 | 3 | push: |
4 | branches: | |
5 | - develop | |
6 | - main | |
7 | - 'feature/**' | |
8 | - 'release/**' | |
9 | - 'fix/**' | |
4 | branches-ignore: | |
5 | # These should always correspond to pull requests, so ignore them for | |
6 | # the push trigger and let them be triggered by the pull_request | |
7 | # trigger, avoiding running the workflow twice. This is a minor | |
8 | # optimization so there's no need to ensure this is comprehensive. | |
9 | - 'dependabot/**' | |
10 | 10 | |
11 | # The branches below must be a subset of the branches above | |
11 | 12 | pull_request: |
12 | 13 | branches: |
13 | 14 | - develop |
18 | 19 | runs-on: ubuntu-latest |
19 | 20 | name: Build and test package documentation |
20 | 21 | |
22 | # The maximum number of minutes to let a workflow run | |
23 | # before GitHub automatically cancels it. Default: 360 | |
24 | timeout-minutes: 30 | |
25 | ||
21 | 26 | steps: |
22 | 27 | - name: Checkout code |
23 | uses: actions/checkout@v3.0.2 | |
28 | uses: actions/checkout@v3.3.0 | |
24 | 29 | |
25 | 30 | - name: Set up Python 3.10 |
26 | uses: actions/setup-python@v4.0.0 | |
31 | uses: actions/setup-python@v4.5.0 | |
27 | 32 | with: |
28 | 33 | python-version: '3.10' |
29 | 34 |
4 | 4 | The format is inspired by `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_ |
5 | 5 | and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_. |
6 | 6 | |
7 | `v0.10.0`_ - 2-March-2023 | |
8 | ------------------------------- | |
9 | Added | |
10 | +++++ | |
11 | - Use the core redis library by default if running Django >= 4.0 | |
12 | `#356 <https://github.com/joke2k/django-environ/issues/356>`_. | |
13 | - Value of dict can now contain an equal sign | |
14 | `#241 <https://github.com/joke2k/django-environ/pull/241>`_. | |
15 | - Added support for Python 3.11. | |
16 | - Added ``CONN_HEALTH_CHECKS`` to database base options | |
17 | `#413 <https://github.com/joke2k/django-environ/issues/413>`_. | |
18 | - Added ``encoding`` parameter to ``read_env`` with default value 'utf8' | |
19 | `#442 <https://github.com/joke2k/django-environ/pull/442>`_. | |
20 | - Added support for Django 4.1 | |
21 | `#416 <https://github.com/joke2k/django-environ/issues/416>`_. | |
22 | ||
23 | Deprecated | |
24 | ++++++++++ | |
25 | - Support of Python < 3.6 is deprecated and will be removed | |
26 | in next major version. | |
27 | ||
28 | Changed | |
29 | +++++++ | |
30 | - Used UTF-8 as a encoding when open ``.env`` file. | |
31 | - Provided access to ```DB_SCHEMES`` through ``cls`` rather than | |
32 | ``Env`` in ``db_url_config`` | |
33 | `#414 <https://github.com/joke2k/django-environ/pull/414>`_. | |
34 | - Correct CI workflow to use supported Python versions/OS matrix | |
35 | `#441 <https://github.com/joke2k/django-environ/pull/441>`_. | |
36 | - Reworked trigger CI workflows strategy | |
37 | `#440 <https://github.com/joke2k/django-environ/pull/440>`_. | |
38 | ||
39 | Fixed | |
40 | +++++ | |
41 | - Fixed logic of ``Env.get_value()`` to skip parsing only when | |
42 | ``default=None``, not for all default values that coerce to ``False`` | |
43 | `#404 <https://github.com/joke2k/django-environ/issues/404>`_. | |
44 | - Deleted duplicated include in docs/quickstart.rst | |
45 | `#439 <https://github.com/joke2k/django-environ/pull/439>`_. | |
46 | ||
47 | Removed | |
48 | +++++++ | |
49 | - Removed deprecated ``Env.unicode()``. | |
50 | - Removed ``environ.register_schemes`` calls and do not modify global | |
51 | ``urllib.parse.urlparse``'s ``uses_*`` variables as this no longer needed | |
52 | `#246 <https://github.com/joke2k/django-environ/pull/246>`_. | |
53 | ||
54 | ||
7 | 55 | `v0.9.0`_ - 15-June-2022 |
8 | ------------------------------ | |
56 | ------------------------ | |
9 | 57 | Added |
10 | 58 | +++++ |
11 | 59 | - Added support for Postgresql cluster URI |
16 | 64 | `#362 <https://github.com/joke2k/django-environ/issues/362>`_. |
17 | 65 | - Amended documentation. |
18 | 66 | |
19 | ||
20 | 67 | Deprecated |
21 | 68 | ++++++++++ |
22 | 69 | - ``Env.unicode()`` is deprecated and will be removed in the next |
23 | 70 | major release. Use ``Env.str()`` instead. |
24 | 71 | |
25 | ||
26 | 72 | Changed |
27 | 73 | +++++++ |
28 | 74 | - Attach cause to ``ImproperlyConfigured`` exception |
29 | 75 | `#360 <https://github.com/joke2k/django-environ/issues/360>`_. |
30 | ||
31 | 76 | |
32 | 77 | Fixed |
33 | 78 | +++++ |
54 | 99 | --------------------------- |
55 | 100 | Added |
56 | 101 | +++++ |
57 | - Log invalid lines when parse .env file | |
102 | - Log invalid lines when parse ``.env`` file | |
58 | 103 | `#283 <https://github.com/joke2k/django-environ/pull/283>`_. |
59 | 104 | - Added docker-style file variable support |
60 | 105 | `#189 <https://github.com/joke2k/django-environ/issues/189>`_. |
66 | 111 | - Added ``pymemcache`` cache backend for Django 3.2+ |
67 | 112 | `#335 <https://github.com/joke2k/django-environ/pull/335>`_. |
68 | 113 | |
69 | ||
70 | 114 | Fixed |
71 | 115 | +++++ |
72 | 116 | - Keep newline/tab escapes in quoted strings |
190 | 234 | +++++ |
191 | 235 | - Fix Path subtracting. |
192 | 236 | |
193 | ||
194 | 237 | `v0.4.3`_ - 21-August-2017 |
195 | 238 | -------------------------- |
196 | 239 | Changed |
197 | 240 | +++++++ |
198 | 241 | - Rollback the default Environ to ``os.environ``. |
242 | ||
199 | 243 | |
200 | 244 | `v0.4.2`_ - 13-April-2017 |
201 | 245 | ------------------------- |
210 | 254 | `#55 <https://github.com/joke2k/django-environ/issues/55>`_. |
211 | 255 | - Update support for ``django-redis`` urls |
212 | 256 | `#109 <https://github.com/joke2k/django-environ/pull/109>`_. |
257 | ||
213 | 258 | |
214 | 259 | `v0.4.1`_ - 13-November-2016 |
215 | 260 | ---------------------------- |
225 | 270 | - Fixed support for Oracle urls. |
226 | 271 | - Fixed support for ``django-redis``. |
227 | 272 | |
273 | ||
228 | 274 | `v0.4`_ - 23-September-2015 |
229 | 275 | --------------------------- |
230 | 276 | Added |
268 | 314 | +++++++ |
269 | 315 | - Rewriting README.rst. |
270 | 316 | |
317 | ||
271 | 318 | v0.2.1 - 19-April-2013 |
272 | 319 | ---------------------- |
273 | 320 | Changed |
274 | 321 | +++++++ |
275 | 322 | - ``Env.__call__`` now uses ``Env.get_value`` instance method. |
276 | 323 | |
324 | ||
277 | 325 | v0.2 - 16-April-2013 |
278 | 326 | -------------------- |
279 | 327 | Added |
284 | 332 | +++++ |
285 | 333 | - Fixed typos in the documentation. |
286 | 334 | |
335 | ||
287 | 336 | v0.1 - 2-April-2013 |
288 | 337 | ------------------- |
289 | 338 | Added |
291 | 340 | - Initial release. |
292 | 341 | |
293 | 342 | |
343 | .. _v0.10.0: https://github.com/joke2k/django-environ/compare/v0.9.0...develop | |
294 | 344 | .. _v0.9.0: https://github.com/joke2k/django-environ/compare/v0.8.1...v0.9.0 |
295 | 345 | .. _v0.8.1: https://github.com/joke2k/django-environ/compare/v0.8.0...v0.8.1 |
296 | 346 | .. _v0.8.0: https://github.com/joke2k/django-environ/compare/v0.7.0...v0.8.0 |
4 | 4 | `current issues <https://github.com/joke2k/django-environ/issues>`_. If there is |
5 | 5 | a bug or feature that you want but it isn't listed, make an issue and work on it. |
6 | 6 | |
7 | How to Contribute | |
8 | ----------------- | |
7 | Bug reports | |
8 | ----------- | |
9 | ||
10 | *Before raising an issue, please ensure that you are using the latest version | |
11 | of django-environ.* | |
12 | ||
13 | Please provide the following information with your issue to enable us to | |
14 | respond as quickly as possible. | |
15 | ||
16 | * The relevant versions of the packages you are using. | |
17 | * The steps to recreate your issue. | |
18 | * The full stacktrace if there is an exception. | |
19 | * An executable code example where possible | |
20 | ||
21 | Guidelines for bug reports: | |
22 | ||
23 | * **Use the GitHub issue search** — check if the issue has already been | |
24 | reported. | |
25 | * **Check if the issue has been fixed** — try to reproduce it using the latest | |
26 | ``main`` or ``develop`` branch in the repository. | |
27 | * Isolate the problem — create a reduced test case and a live example. | |
28 | ||
29 | A good bug report shouldn't leave others needing to chase you up for more | |
30 | information. Please try to be as detailed as possible in your report. What is | |
31 | your environment? What steps will reproduce the issue? What OS experience the | |
32 | problem? What would you expect to be the outcome? All these details will help | |
33 | people to fix any potential bugs. | |
34 | ||
35 | Feature requests | |
36 | ---------------- | |
37 | ||
38 | Feature requests are welcome. But take a moment to find out whether your idea | |
39 | fits with the scope and aims of the project. It's up to *you* to make a strong | |
40 | case to convince the project's developers of the merits of this feature. Please | |
41 | provide as much detail and context as possible. | |
42 | ||
43 | Pull requests | |
44 | ------------- | |
45 | ||
46 | Good pull requests - patches, improvements, new features - are a fantastic | |
47 | help. They should remain focused in scope and avoid containing unrelated | |
48 | commits. | |
49 | ||
50 | Follow this process if you'd like your work considered for inclusion in the | |
51 | project: | |
9 | 52 | |
10 | 53 | 1. Check for open issues or open a fresh issue to start a discussion around a |
11 | 54 | feature idea or a bug. |
12 | 2. Fork `the repository <https://github.com/joke2k/django-environ>`_ on GitHub | |
13 | to start making your changes to the **develop** branch (or branch off of it). | |
55 | 2. Fork `the repository <https://github.com/joke2k/django-environ>`_ | |
56 | on GitHub to start making your changes to the ``develop`` branch | |
57 | (or branch off of it). | |
14 | 58 | 3. Write a test which shows that the bug was fixed or that the feature works as |
15 | 59 | expected. |
16 | 60 | 4. Send a pull request and bug the maintainer until it gets merged and published. |
61 | ||
62 | If you are intending to implement a fairly large feature we'd appreciate if you | |
63 | open an issue with GitHub detailing your use case and intended solution to | |
64 | discuss how it might impact other work that is in flight. | |
65 | ||
66 | We also appreciate it if you take the time to update and write tests for any | |
67 | changes you submit. | |
68 | ||
69 | **By submitting a patch, you agree to allow the project owner to license your | |
70 | work under the same license as that used by the project.** | |
71 | ||
72 | Resources | |
73 | --------- | |
74 | ||
75 | * `How to Contribute to Open Source <https://opensource.guide/how-to-contribute/>`_ | |
76 | * `Using Pull Requests <https://help.github.com/articles/about-pull-requests/>`_ | |
77 | * `Writing good commit messages <http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_ |
0 | 0 | Metadata-Version: 2.1 |
1 | 1 | Name: django-environ |
2 | Version: 0.9.0 | |
2 | Version: 0.10.0 | |
3 | 3 | Summary: A package that allows you to utilize 12factor inspired environment variables to configure your Django application. |
4 | 4 | Home-page: https://django-environ.readthedocs.org |
5 | 5 | Author: Daniele Faraglia |
25 | 25 | Classifier: Framework :: Django :: 3.1 |
26 | 26 | Classifier: Framework :: Django :: 3.2 |
27 | 27 | Classifier: Framework :: Django :: 4.0 |
28 | Classifier: Framework :: Django :: 4.1 | |
28 | 29 | Classifier: Operating System :: OS Independent |
29 | 30 | Classifier: Intended Audience :: Developers |
30 | 31 | Classifier: Natural Language :: English |
31 | 32 | Classifier: Programming Language :: Python |
32 | 33 | Classifier: Programming Language :: Python :: 3 |
33 | Classifier: Programming Language :: Python :: 3.4 | |
34 | 34 | Classifier: Programming Language :: Python :: 3.5 |
35 | 35 | Classifier: Programming Language :: Python :: 3.6 |
36 | 36 | Classifier: Programming Language :: Python :: 3.7 |
37 | 37 | Classifier: Programming Language :: Python :: 3.8 |
38 | 38 | Classifier: Programming Language :: Python :: 3.9 |
39 | 39 | Classifier: Programming Language :: Python :: 3.10 |
40 | Classifier: Programming Language :: Python :: 3.11 | |
40 | 41 | Classifier: Programming Language :: Python :: Implementation :: CPython |
41 | 42 | Classifier: Programming Language :: Python :: Implementation :: PyPy |
42 | 43 | Classifier: Topic :: Software Development :: Libraries :: Python Modules |
43 | 44 | Classifier: Topic :: Utilities |
44 | 45 | Classifier: License :: OSI Approved :: MIT License |
45 | Requires-Python: >=3.4,<4 | |
46 | Requires-Python: >=3.5,<4 | |
46 | 47 | Description-Content-Type: text/x-rst |
47 | 48 | Provides-Extra: testing |
48 | 49 | Provides-Extra: docs |
155 | 156 | and the latest release on `PyPI <https://pypi.org/project/django-environ/>`_. |
156 | 157 | |
157 | 158 | It’s rigorously tested on Python 3.5+, and officially supports |
158 | Django 1.11, 2.2, 3.0, 3.1, 3.2 and 4.0. | |
159 | Django 1.11, 2.2, 3., 3.1, 3.2, 4.0 and 4.1. | |
159 | 160 | |
160 | 161 | If you'd like to contribute to ``django-environ`` you're most welcome! |
161 | 162 | |
176 | 177 | `current issues <https://github.com/joke2k/django-environ/issues>`_. If there is |
177 | 178 | a bug or feature that you want but it isn't listed, make an issue and work on it. |
178 | 179 | |
179 | How to Contribute | |
180 | ----------------- | |
180 | Bug reports | |
181 | ----------- | |
182 | ||
183 | *Before raising an issue, please ensure that you are using the latest version | |
184 | of django-environ.* | |
185 | ||
186 | Please provide the following information with your issue to enable us to | |
187 | respond as quickly as possible. | |
188 | ||
189 | * The relevant versions of the packages you are using. | |
190 | * The steps to recreate your issue. | |
191 | * The full stacktrace if there is an exception. | |
192 | * An executable code example where possible | |
193 | ||
194 | Guidelines for bug reports: | |
195 | ||
196 | * **Use the GitHub issue search** — check if the issue has already been | |
197 | reported. | |
198 | * **Check if the issue has been fixed** — try to reproduce it using the latest | |
199 | ``main`` or ``develop`` branch in the repository. | |
200 | * Isolate the problem — create a reduced test case and a live example. | |
201 | ||
202 | A good bug report shouldn't leave others needing to chase you up for more | |
203 | information. Please try to be as detailed as possible in your report. What is | |
204 | your environment? What steps will reproduce the issue? What OS experience the | |
205 | problem? What would you expect to be the outcome? All these details will help | |
206 | people to fix any potential bugs. | |
207 | ||
208 | Feature requests | |
209 | ---------------- | |
210 | ||
211 | Feature requests are welcome. But take a moment to find out whether your idea | |
212 | fits with the scope and aims of the project. It's up to *you* to make a strong | |
213 | case to convince the project's developers of the merits of this feature. Please | |
214 | provide as much detail and context as possible. | |
215 | ||
216 | Pull requests | |
217 | ------------- | |
218 | ||
219 | Good pull requests - patches, improvements, new features - are a fantastic | |
220 | help. They should remain focused in scope and avoid containing unrelated | |
221 | commits. | |
222 | ||
223 | Follow this process if you'd like your work considered for inclusion in the | |
224 | project: | |
181 | 225 | |
182 | 226 | 1. Check for open issues or open a fresh issue to start a discussion around a |
183 | 227 | feature idea or a bug. |
184 | 2. Fork `the repository <https://github.com/joke2k/django-environ>`_ on GitHub | |
185 | to start making your changes to the **develop** branch (or branch off of it). | |
228 | 2. Fork `the repository <https://github.com/joke2k/django-environ>`_ | |
229 | on GitHub to start making your changes to the ``develop`` branch | |
230 | (or branch off of it). | |
186 | 231 | 3. Write a test which shows that the bug was fixed or that the feature works as |
187 | 232 | expected. |
188 | 233 | 4. Send a pull request and bug the maintainer until it gets merged and published. |
189 | 234 | |
235 | If you are intending to implement a fairly large feature we'd appreciate if you | |
236 | open an issue with GitHub detailing your use case and intended solution to | |
237 | discuss how it might impact other work that is in flight. | |
238 | ||
239 | We also appreciate it if you take the time to update and write tests for any | |
240 | changes you submit. | |
241 | ||
242 | **By submitting a patch, you agree to allow the project owner to license your | |
243 | work under the same license as that used by the project.** | |
244 | ||
245 | Resources | |
246 | --------- | |
247 | ||
248 | * `How to Contribute to Open Source <https://opensource.guide/how-to-contribute/>`_ | |
249 | * `Using Pull Requests <https://help.github.com/articles/about-pull-requests/>`_ | |
250 | * `Writing good commit messages <http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_ | |
251 | ||
190 | 252 | |
191 | 253 | Release Information |
192 | 254 | =================== |
193 | 255 | |
194 | v0.9.0 - 15-June-2022 | |
195 | ------------------------------ | |
256 | v0.10.0 - 2-March-2023 | |
257 | ------------------------------- | |
196 | 258 | Added |
197 | 259 | +++++ |
198 | - Added support for Postgresql cluster URI | |
199 | `#355 <https://github.com/joke2k/django-environ/pull/355>`_. | |
200 | - Added support for Django 4.0 | |
201 | `#371 <https://github.com/joke2k/django-environ/issues/371>`_. | |
202 | - Added support for prefixed variables | |
203 | `#362 <https://github.com/joke2k/django-environ/issues/362>`_. | |
204 | - Amended documentation. | |
205 | ||
260 | - Use the core redis library by default if running Django >= 4.0 | |
261 | `#356 <https://github.com/joke2k/django-environ/issues/356>`_. | |
262 | - Value of dict can now contain an equal sign | |
263 | `#241 <https://github.com/joke2k/django-environ/pull/241>`_. | |
264 | - Added support for Python 3.11. | |
265 | - Added ``CONN_HEALTH_CHECKS`` to database base options | |
266 | `#413 <https://github.com/joke2k/django-environ/issues/413>`_. | |
267 | - Added ``encoding`` parameter to ``read_env`` with default value 'utf8' | |
268 | `#442 <https://github.com/joke2k/django-environ/pull/442>`_. | |
269 | - Added support for Django 4.1 | |
270 | `#416 <https://github.com/joke2k/django-environ/issues/416>`_. | |
206 | 271 | |
207 | 272 | Deprecated |
208 | 273 | ++++++++++ |
209 | - ``Env.unicode()`` is deprecated and will be removed in the next | |
210 | major release. Use ``Env.str()`` instead. | |
211 | ||
274 | - Support of Python < 3.6 is deprecated and will be removed | |
275 | in next major version. | |
212 | 276 | |
213 | 277 | Changed |
214 | 278 | +++++++ |
215 | - Attach cause to ``ImproperlyConfigured`` exception | |
216 | `#360 <https://github.com/joke2k/django-environ/issues/360>`_. | |
217 | ||
279 | - Used UTF-8 as a encoding when open ``.env`` file. | |
280 | - Provided access to ```DB_SCHEMES`` through ``cls`` rather than | |
281 | ``Env`` in ``db_url_config`` | |
282 | `#414 <https://github.com/joke2k/django-environ/pull/414>`_. | |
283 | - Correct CI workflow to use supported Python versions/OS matrix | |
284 | `#441 <https://github.com/joke2k/django-environ/pull/441>`_. | |
285 | - Reworked trigger CI workflows strategy | |
286 | `#440 <https://github.com/joke2k/django-environ/pull/440>`_. | |
218 | 287 | |
219 | 288 | Fixed |
220 | 289 | +++++ |
221 | - Fixed ``_cast_urlstr`` unquoting | |
222 | `#357 <https://github.com/joke2k/django-environ/issues/357>`_. | |
223 | - Fixed documentation regarding unsafe characters in URLs | |
224 | `#220 <https://github.com/joke2k/django-environ/issues/220>`_. | |
225 | - Fixed ``environ.Path.__eq__()`` to compare paths correctly | |
226 | `#86 <https://github.com/joke2k/django-environ/issues/86>`_, | |
227 | `#197 <https://github.com/joke2k/django-environ/issues/197>`_. | |
290 | - Fixed logic of ``Env.get_value()`` to skip parsing only when | |
291 | ``default=None``, not for all default values that coerce to ``False`` | |
292 | `#404 <https://github.com/joke2k/django-environ/issues/404>`_. | |
293 | - Deleted duplicated include in docs/quickstart.rst | |
294 | `#439 <https://github.com/joke2k/django-environ/pull/439>`_. | |
295 | ||
296 | Removed | |
297 | +++++++ | |
298 | - Removed deprecated ``Env.unicode()``. | |
299 | - Removed ``environ.register_schemes`` calls and do not modify global | |
300 | ``urllib.parse.urlparse``'s ``uses_*`` variables as this no longer needed | |
301 | `#246 <https://github.com/joke2k/django-environ/pull/246>`_. | |
228 | 302 | |
229 | 303 | `Full changelog <https://django-environ.readthedocs.org/en/latest/changelog.html>`_. |
230 | 304 |
126 | 126 | and the latest release on `PyPI <https://pypi.org/project/django-environ/>`_. |
127 | 127 | |
128 | 128 | It’s rigorously tested on Python 3.5+, and officially supports |
129 | Django 1.11, 2.2, 3.0, 3.1, 3.2 and 4.0. | |
129 | Django 1.11, 2.2, 3., 3.1, 3.2, 4.0 and 4.1. | |
130 | 130 | |
131 | 131 | If you'd like to contribute to ``django-environ`` you're most welcome! |
132 | 132 |
0 | django-environ (0.9.0-1) UNRELEASED; urgency=low | |
0 | django-environ (0.10.0-1) UNRELEASED; urgency=low | |
1 | 1 | |
2 | 2 | * New upstream release. |
3 | * New upstream release. | |
3 | 4 | |
4 | -- Debian Janitor <janitor@jelmer.uk> Tue, 31 Jan 2023 16:58:43 -0000 | |
5 | -- Debian Janitor <janitor@jelmer.uk> Wed, 09 Aug 2023 21:05:02 -0000 | |
5 | 6 | |
6 | 7 | django-environ (0.4.4-5) unstable; urgency=medium |
7 | 8 |
0 | 0 | Metadata-Version: 2.1 |
1 | 1 | Name: django-environ |
2 | Version: 0.9.0 | |
2 | Version: 0.10.0 | |
3 | 3 | Summary: A package that allows you to utilize 12factor inspired environment variables to configure your Django application. |
4 | 4 | Home-page: https://django-environ.readthedocs.org |
5 | 5 | Author: Daniele Faraglia |
25 | 25 | Classifier: Framework :: Django :: 3.1 |
26 | 26 | Classifier: Framework :: Django :: 3.2 |
27 | 27 | Classifier: Framework :: Django :: 4.0 |
28 | Classifier: Framework :: Django :: 4.1 | |
28 | 29 | Classifier: Operating System :: OS Independent |
29 | 30 | Classifier: Intended Audience :: Developers |
30 | 31 | Classifier: Natural Language :: English |
31 | 32 | Classifier: Programming Language :: Python |
32 | 33 | Classifier: Programming Language :: Python :: 3 |
33 | Classifier: Programming Language :: Python :: 3.4 | |
34 | 34 | Classifier: Programming Language :: Python :: 3.5 |
35 | 35 | Classifier: Programming Language :: Python :: 3.6 |
36 | 36 | Classifier: Programming Language :: Python :: 3.7 |
37 | 37 | Classifier: Programming Language :: Python :: 3.8 |
38 | 38 | Classifier: Programming Language :: Python :: 3.9 |
39 | 39 | Classifier: Programming Language :: Python :: 3.10 |
40 | Classifier: Programming Language :: Python :: 3.11 | |
40 | 41 | Classifier: Programming Language :: Python :: Implementation :: CPython |
41 | 42 | Classifier: Programming Language :: Python :: Implementation :: PyPy |
42 | 43 | Classifier: Topic :: Software Development :: Libraries :: Python Modules |
43 | 44 | Classifier: Topic :: Utilities |
44 | 45 | Classifier: License :: OSI Approved :: MIT License |
45 | Requires-Python: >=3.4,<4 | |
46 | Requires-Python: >=3.5,<4 | |
46 | 47 | Description-Content-Type: text/x-rst |
47 | 48 | Provides-Extra: testing |
48 | 49 | Provides-Extra: docs |
155 | 156 | and the latest release on `PyPI <https://pypi.org/project/django-environ/>`_. |
156 | 157 | |
157 | 158 | It’s rigorously tested on Python 3.5+, and officially supports |
158 | Django 1.11, 2.2, 3.0, 3.1, 3.2 and 4.0. | |
159 | Django 1.11, 2.2, 3., 3.1, 3.2, 4.0 and 4.1. | |
159 | 160 | |
160 | 161 | If you'd like to contribute to ``django-environ`` you're most welcome! |
161 | 162 | |
176 | 177 | `current issues <https://github.com/joke2k/django-environ/issues>`_. If there is |
177 | 178 | a bug or feature that you want but it isn't listed, make an issue and work on it. |
178 | 179 | |
179 | How to Contribute | |
180 | ----------------- | |
180 | Bug reports | |
181 | ----------- | |
182 | ||
183 | *Before raising an issue, please ensure that you are using the latest version | |
184 | of django-environ.* | |
185 | ||
186 | Please provide the following information with your issue to enable us to | |
187 | respond as quickly as possible. | |
188 | ||
189 | * The relevant versions of the packages you are using. | |
190 | * The steps to recreate your issue. | |
191 | * The full stacktrace if there is an exception. | |
192 | * An executable code example where possible | |
193 | ||
194 | Guidelines for bug reports: | |
195 | ||
196 | * **Use the GitHub issue search** — check if the issue has already been | |
197 | reported. | |
198 | * **Check if the issue has been fixed** — try to reproduce it using the latest | |
199 | ``main`` or ``develop`` branch in the repository. | |
200 | * Isolate the problem — create a reduced test case and a live example. | |
201 | ||
202 | A good bug report shouldn't leave others needing to chase you up for more | |
203 | information. Please try to be as detailed as possible in your report. What is | |
204 | your environment? What steps will reproduce the issue? What OS experience the | |
205 | problem? What would you expect to be the outcome? All these details will help | |
206 | people to fix any potential bugs. | |
207 | ||
208 | Feature requests | |
209 | ---------------- | |
210 | ||
211 | Feature requests are welcome. But take a moment to find out whether your idea | |
212 | fits with the scope and aims of the project. It's up to *you* to make a strong | |
213 | case to convince the project's developers of the merits of this feature. Please | |
214 | provide as much detail and context as possible. | |
215 | ||
216 | Pull requests | |
217 | ------------- | |
218 | ||
219 | Good pull requests - patches, improvements, new features - are a fantastic | |
220 | help. They should remain focused in scope and avoid containing unrelated | |
221 | commits. | |
222 | ||
223 | Follow this process if you'd like your work considered for inclusion in the | |
224 | project: | |
181 | 225 | |
182 | 226 | 1. Check for open issues or open a fresh issue to start a discussion around a |
183 | 227 | feature idea or a bug. |
184 | 2. Fork `the repository <https://github.com/joke2k/django-environ>`_ on GitHub | |
185 | to start making your changes to the **develop** branch (or branch off of it). | |
228 | 2. Fork `the repository <https://github.com/joke2k/django-environ>`_ | |
229 | on GitHub to start making your changes to the ``develop`` branch | |
230 | (or branch off of it). | |
186 | 231 | 3. Write a test which shows that the bug was fixed or that the feature works as |
187 | 232 | expected. |
188 | 233 | 4. Send a pull request and bug the maintainer until it gets merged and published. |
189 | 234 | |
235 | If you are intending to implement a fairly large feature we'd appreciate if you | |
236 | open an issue with GitHub detailing your use case and intended solution to | |
237 | discuss how it might impact other work that is in flight. | |
238 | ||
239 | We also appreciate it if you take the time to update and write tests for any | |
240 | changes you submit. | |
241 | ||
242 | **By submitting a patch, you agree to allow the project owner to license your | |
243 | work under the same license as that used by the project.** | |
244 | ||
245 | Resources | |
246 | --------- | |
247 | ||
248 | * `How to Contribute to Open Source <https://opensource.guide/how-to-contribute/>`_ | |
249 | * `Using Pull Requests <https://help.github.com/articles/about-pull-requests/>`_ | |
250 | * `Writing good commit messages <http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_ | |
251 | ||
190 | 252 | |
191 | 253 | Release Information |
192 | 254 | =================== |
193 | 255 | |
194 | v0.9.0 - 15-June-2022 | |
195 | ------------------------------ | |
256 | v0.10.0 - 2-March-2023 | |
257 | ------------------------------- | |
196 | 258 | Added |
197 | 259 | +++++ |
198 | - Added support for Postgresql cluster URI | |
199 | `#355 <https://github.com/joke2k/django-environ/pull/355>`_. | |
200 | - Added support for Django 4.0 | |
201 | `#371 <https://github.com/joke2k/django-environ/issues/371>`_. | |
202 | - Added support for prefixed variables | |
203 | `#362 <https://github.com/joke2k/django-environ/issues/362>`_. | |
204 | - Amended documentation. | |
205 | ||
260 | - Use the core redis library by default if running Django >= 4.0 | |
261 | `#356 <https://github.com/joke2k/django-environ/issues/356>`_. | |
262 | - Value of dict can now contain an equal sign | |
263 | `#241 <https://github.com/joke2k/django-environ/pull/241>`_. | |
264 | - Added support for Python 3.11. | |
265 | - Added ``CONN_HEALTH_CHECKS`` to database base options | |
266 | `#413 <https://github.com/joke2k/django-environ/issues/413>`_. | |
267 | - Added ``encoding`` parameter to ``read_env`` with default value 'utf8' | |
268 | `#442 <https://github.com/joke2k/django-environ/pull/442>`_. | |
269 | - Added support for Django 4.1 | |
270 | `#416 <https://github.com/joke2k/django-environ/issues/416>`_. | |
206 | 271 | |
207 | 272 | Deprecated |
208 | 273 | ++++++++++ |
209 | - ``Env.unicode()`` is deprecated and will be removed in the next | |
210 | major release. Use ``Env.str()`` instead. | |
211 | ||
274 | - Support of Python < 3.6 is deprecated and will be removed | |
275 | in next major version. | |
212 | 276 | |
213 | 277 | Changed |
214 | 278 | +++++++ |
215 | - Attach cause to ``ImproperlyConfigured`` exception | |
216 | `#360 <https://github.com/joke2k/django-environ/issues/360>`_. | |
217 | ||
279 | - Used UTF-8 as a encoding when open ``.env`` file. | |
280 | - Provided access to ```DB_SCHEMES`` through ``cls`` rather than | |
281 | ``Env`` in ``db_url_config`` | |
282 | `#414 <https://github.com/joke2k/django-environ/pull/414>`_. | |
283 | - Correct CI workflow to use supported Python versions/OS matrix | |
284 | `#441 <https://github.com/joke2k/django-environ/pull/441>`_. | |
285 | - Reworked trigger CI workflows strategy | |
286 | `#440 <https://github.com/joke2k/django-environ/pull/440>`_. | |
218 | 287 | |
219 | 288 | Fixed |
220 | 289 | +++++ |
221 | - Fixed ``_cast_urlstr`` unquoting | |
222 | `#357 <https://github.com/joke2k/django-environ/issues/357>`_. | |
223 | - Fixed documentation regarding unsafe characters in URLs | |
224 | `#220 <https://github.com/joke2k/django-environ/issues/220>`_. | |
225 | - Fixed ``environ.Path.__eq__()`` to compare paths correctly | |
226 | `#86 <https://github.com/joke2k/django-environ/issues/86>`_, | |
227 | `#197 <https://github.com/joke2k/django-environ/issues/197>`_. | |
290 | - Fixed logic of ``Env.get_value()`` to skip parsing only when | |
291 | ``default=None``, not for all default values that coerce to ``False`` | |
292 | `#404 <https://github.com/joke2k/django-environ/issues/404>`_. | |
293 | - Deleted duplicated include in docs/quickstart.rst | |
294 | `#439 <https://github.com/joke2k/django-environ/pull/439>`_. | |
295 | ||
296 | Removed | |
297 | +++++++ | |
298 | - Removed deprecated ``Env.unicode()``. | |
299 | - Removed ``environ.register_schemes`` calls and do not modify global | |
300 | ``urllib.parse.urlparse``'s ``uses_*`` variables as this no longer needed | |
301 | `#246 <https://github.com/joke2k/django-environ/pull/246>`_. | |
228 | 302 | |
229 | 303 | `Full changelog <https://django-environ.readthedocs.org/en/latest/changelog.html>`_. |
230 | 304 |
12 | 12 | .github/FUNDING.yml |
13 | 13 | .github/dependabot.yml |
14 | 14 | .github/workflows/build.yml |
15 | .github/workflows/change-pr-target.yml | |
15 | 16 | .github/workflows/ci.yml |
17 | .github/workflows/codeql.yml | |
16 | 18 | .github/workflows/cs.yml |
17 | 19 | .github/workflows/docs.yml |
18 | 20 | django_environ.egg-info/PKG-INFO |
125 | 125 | # In nitpick mode (-n), still ignore any of the following "broken" references |
126 | 126 | # to non-types. |
127 | 127 | nitpick_ignore = [ |
128 | ('py:func', 'str.rfind'), | |
129 | ('py:func', 'str.find'), | |
128 | 130 | ] |
129 | 131 | |
130 | 132 | # |
0 | 0 | ============ |
1 | 1 | Deprecations |
2 | 2 | ============ |
3 | ||
4 | Features deprecated in 0.10.0 | |
5 | ============================= | |
6 | ||
7 | Python | |
8 | ------ | |
9 | ||
10 | * Support of Python < 3.6 is deprecated and will be removed | |
11 | in next major version. | |
12 | ||
3 | 13 | |
4 | 14 | Features deprecated in 0.9.0 |
5 | 15 | ============================ |
7 | 17 | Methods |
8 | 18 | ------- |
9 | 19 | |
10 | * The :meth:`.environ.Env.unicode` method is deprecated as it was used | |
20 | * The ``environ.Env.unicode`` method is deprecated as it was used | |
11 | 21 | for Python 2.x only. Use :meth:`.environ.Env.str` instead. |
4 | 4 | |
5 | 5 | #. **Can django-environ determine the location of .env file automatically?** |
6 | 6 | |
7 | ``django-environ`` will try to get and read ``.env`` file from the project | |
7 | django-environ will try to get and read ``.env`` file from the project | |
8 | 8 | root if you haven't specified the path for it when call :meth:`.environ.Env.read_env`. |
9 | 9 | However, this is not the recommended way. When it is possible always specify |
10 | 10 | the path tho ``.env`` file. Alternatively, you can use a trick with a |
26 | 26 | |
27 | 27 | #. **Is .env file going to be imported in settings file?** |
28 | 28 | |
29 | No need to import, ``django-environ`` automatically picks variables | |
29 | No need to import, django-environ automatically picks variables | |
30 | 30 | from there. |
31 | ||
32 | #. **Should I commit my .env file?** | |
33 | ||
34 | Credentials should only be accessible on the machines that need access to them. | |
35 | Never commit sensitive information to a repository that is not needed by every | |
36 | development machine and server. | |
37 | ||
38 | #. **Why is it not overriding existing environment variables?** | |
39 | ||
40 | By default, django-environ won't overwrite existing environment variables as | |
41 | it assumes the deployment environment has more knowledge about configuration | |
42 | than the application does. To overwrite existing environment variables you can | |
43 | pass ``overwrite=True`` to :meth:`.environ.Env.read_env`. For more see | |
44 | ":ref:`overwriting-existing-env`" |
11 | 11 | Installing django-environ |
12 | 12 | ========================= |
13 | 13 | |
14 | ``django-environ`` is a Python-only package `hosted_on_pypi`_. | |
14 | django-environ is a Python-only package `hosted_on_pypi`_. | |
15 | 15 | The recommended installation method is `pip`_-installing into a |
16 | 16 | :mod:`virtualenv <python:venv>`: |
17 | 17 | |
21 | 21 | |
22 | 22 | .. note:: |
23 | 23 | |
24 | After installing ``django-environ``, no need to add it to ``INSTALLED_APPS``. | |
24 | After installing django-environ, no need to add it to ``INSTALLED_APPS``. | |
25 | 25 | |
26 | 26 | |
27 | 27 | .. _hosted_on_pypi: https://pypi.org/project/django-environ/ |
42 | 42 | # OR |
43 | 43 | $ pip install --upgrade https://github.com/joke2k/django-environ.git/archive/develop.tar.gz |
44 | 44 | |
45 | This command will download the latest version of ``django-environ`` and install | |
45 | This command will download the latest version of django-environ and install | |
46 | 46 | it to your system. |
47 | 47 | |
48 | 48 | .. note:: |
1 | 1 | License and Credits |
2 | 2 | =================== |
3 | 3 | |
4 | ``django-environ`` is open source software licensed under the | |
4 | django-environ is open source software licensed under the | |
5 | 5 | `MIT / X11 License <https://choosealicense.com/licenses/mit/>`_. |
6 | 6 | The full license text can be also found in the `source code repository <https://github.com/joke2k/django-environ/blob/main/LICENSE.txt>`_. |
7 | 7 |
0 | 0 | =========== |
1 | 1 | Quick Start |
2 | 2 | =========== |
3 | ||
4 | .. include:: ../README.rst | |
5 | :start-after: -code-begin- | |
6 | :end-before: -overview- | |
7 | 3 | |
8 | 4 | Usage |
9 | 5 | ===== |
54 | 54 | Smart Casting |
55 | 55 | ============= |
56 | 56 | |
57 | ``django-environ`` has a "Smart-casting" enabled by default, if you don't provide a ``cast`` type, it will be detected from ``default`` type. | |
57 | django-environ has a "Smart-casting" enabled by default, if you don't provide a ``cast`` type, it will be detected from ``default`` type. | |
58 | 58 | This could raise side effects (see `#192 <https://github.com/joke2k/django-environ/issues/192>`_). |
59 | 59 | To disable it use ``env.smart_cast = False``. |
60 | 60 | |
316 | 316 | env.read_env(pathlib.Path(str(BASE_DIR)) / '.env') |
317 | 317 | |
318 | 318 | |
319 | .. _overwriting-existing-env: | |
320 | ||
319 | 321 | Overwriting existing environment values from env files |
320 | 322 | ------------------------------------------------------ |
321 | 323 |
17 | 17 | from .environ import * |
18 | 18 | |
19 | 19 | |
20 | __copyright__ = 'Copyright (C) 2021 Daniele Faraglia' | |
20 | __copyright__ = 'Copyright (C) 2013-2022 Daniele Faraglia' | |
21 | 21 | """The copyright notice of the package.""" |
22 | 22 | |
23 | __version__ = '0.9.0' | |
23 | __version__ = '0.10.0' | |
24 | 24 | """The version of the package.""" |
25 | 25 | |
26 | 26 | __license__ = 'MIT' |
41 | 41 | __url__ = 'https://django-environ.readthedocs.org' |
42 | 42 | """The URL of the package.""" |
43 | 43 | |
44 | # pylint: disable=line-too-long | |
44 | 45 | __description__ = 'A package that allows you to utilize 12factor inspired environment variables to configure your Django application.' # noqa: E501 |
45 | 46 | """The description of the package.""" |
22 | 22 | DJANGO_VERSION = None |
23 | 23 | |
24 | 24 | class ImproperlyConfigured(Exception): |
25 | pass | |
25 | """Django is somehow improperly configured""" | |
26 | 26 | |
27 | # back compatibility with django postgresql package | |
28 | if DJANGO_VERSION is not None and DJANGO_VERSION < (2, 0): | |
29 | DJANGO_POSTGRES = 'django.db.backends.postgresql_psycopg2' | |
30 | else: | |
31 | # https://docs.djangoproject.com/en/2.0/releases/2.0/#id1 | |
32 | DJANGO_POSTGRES = 'django.db.backends.postgresql' | |
33 | 27 | |
34 | # back compatibility with redis_cache package | |
35 | if find_loader('redis_cache'): | |
36 | REDIS_DRIVER = 'redis_cache.RedisCache' | |
37 | else: | |
38 | REDIS_DRIVER = 'django_redis.cache.RedisCache' | |
28 | def choose_rediscache_driver(): | |
29 | """Backward compatibility for RedisCache driver.""" | |
30 | # use built-in support if Django 4+ | |
31 | if DJANGO_VERSION is not None and DJANGO_VERSION >= (4, 0): | |
32 | return 'django.core.cache.backends.redis.RedisCache' | |
33 | ||
34 | # back compatibility with redis_cache package | |
35 | if find_loader('redis_cache'): | |
36 | return 'redis_cache.RedisCache' | |
37 | return 'django_redis.cache.RedisCache' | |
38 | ||
39 | ||
40 | def choose_postgres_driver(): | |
41 | """Backward compatibility for postgresql driver.""" | |
42 | old_django = DJANGO_VERSION is not None and DJANGO_VERSION < (2, 0) | |
43 | if old_django: | |
44 | return 'django.db.backends.postgresql_psycopg2' | |
45 | return 'django.db.backends.postgresql' | |
39 | 46 | |
40 | 47 | |
41 | 48 | def choose_pymemcache_driver(): |
48 | 55 | return 'django.core.cache.backends.memcached.PyMemcacheCache' |
49 | 56 | |
50 | 57 | |
58 | REDIS_DRIVER = choose_rediscache_driver() | |
59 | """The name of the RedisCache driver.""" | |
60 | ||
61 | DJANGO_POSTGRES = choose_postgres_driver() | |
62 | """The name of the PostgreSQL driver.""" | |
63 | ||
51 | 64 | PYMEMCACHE_DRIVER = choose_pymemcache_driver() |
65 | """The name of the Pymemcache driver.""" |
16 | 16 | import os |
17 | 17 | import re |
18 | 18 | import sys |
19 | import urllib.parse as urlparselib | |
20 | 19 | import warnings |
21 | 20 | from urllib.parse import ( |
22 | 21 | parse_qs, |
66 | 65 | |
67 | 66 | |
68 | 67 | class NoValue: |
68 | """Represent of no value object.""" | |
69 | 69 | |
70 | 70 | def __repr__(self): |
71 | 71 | return '<{}>'.format(self.__class__.__name__) |
133 | 133 | 'ATOMIC_REQUESTS', |
134 | 134 | 'AUTOCOMMIT', |
135 | 135 | 'DISABLE_SERVER_SIDE_CURSORS', |
136 | 'CONN_HEALTH_CHECKS', | |
136 | 137 | ] |
137 | 138 | |
138 | 139 | DEFAULT_CACHE_ENV = 'CACHE_URL' |
203 | 204 | def __contains__(self, var): |
204 | 205 | return var in self.ENVIRON |
205 | 206 | |
206 | # Shortcuts | |
207 | ||
208 | 207 | def str(self, var, default=NOTSET, multiline=False): |
209 | 208 | """ |
210 | 209 | :rtype: str |
213 | 212 | if multiline: |
214 | 213 | return re.sub(r'(\\r)?\\n', r'\n', value) |
215 | 214 | return value |
216 | ||
217 | def unicode(self, var, default=NOTSET): | |
218 | """Helper for python2 | |
219 | :rtype: unicode | |
220 | """ | |
221 | warnings.warn( | |
222 | '`%s.unicode` is deprecated, use `%s.str` instead' % ( | |
223 | self.__class__.__name__, | |
224 | self.__class__.__name__, | |
225 | ), | |
226 | DeprecationWarning, | |
227 | stacklevel=2 | |
228 | ) | |
229 | ||
230 | return self.get_value(var, cast=str, default=default) | |
231 | 215 | |
232 | 216 | def bytes(self, var, default=NOTSET, encoding='utf8'): |
233 | 217 | """ |
372 | 356 | :rtype: typing.IO[typing.Any] |
373 | 357 | """ |
374 | 358 | |
375 | logger.debug("get '{}' casted as '{}' with default '{}'".format( | |
376 | var, cast, default | |
377 | )) | |
359 | logger.debug( | |
360 | "get '%s' casted as '%s' with default '%s'", | |
361 | var, cast, default) | |
378 | 362 | |
379 | 363 | var_name = "{}{}".format(self.prefix, var) |
380 | 364 | if var_name in self.scheme: |
425 | 409 | |
426 | 410 | value = None if default is None and value == '' else value |
427 | 411 | |
428 | if value != default or (parse_default and value): | |
412 | if value != default or (parse_default and value is not None): | |
429 | 413 | value = self.parse_value(value, cast) |
430 | 414 | |
431 | 415 | return value |
432 | ||
433 | # Class and static methods | |
434 | 416 | |
435 | 417 | @classmethod |
436 | 418 | def parse_value(cls, value, cast): |
443 | 425 | """ |
444 | 426 | if cast is None: |
445 | 427 | return value |
446 | elif cast is bool: | |
428 | if cast is bool: | |
447 | 429 | try: |
448 | 430 | value = int(value) != 0 |
449 | 431 | except ValueError: |
456 | 438 | elif isinstance(cast, dict): |
457 | 439 | key_cast = cast.get('key', str) |
458 | 440 | value_cast = cast.get('value', str) |
459 | value_cast_by_key = cast.get('cast', dict()) | |
441 | value_cast_by_key = cast.get('cast', {}) | |
460 | 442 | value = dict(map( |
461 | 443 | lambda kv: ( |
462 | 444 | key_cast(kv[0]), |
468 | 450 | [val.split('=') for val in value.split(';') if val] |
469 | 451 | )) |
470 | 452 | elif cast is dict: |
471 | value = dict([val.split('=') for val in value.split(',') if val]) | |
453 | value = dict([v.split('=', 1) for v in value.split(',') if v]) | |
472 | 454 | elif cast is list: |
473 | 455 | value = [x for x in value.split(',') if x] |
474 | 456 | elif cast is tuple: |
475 | 457 | val = value.strip('(').strip(')').split(',') |
458 | # pylint: disable=consider-using-generator | |
476 | 459 | value = tuple([x for x in val if x]) |
477 | 460 | elif cast is float: |
478 | 461 | # clean string |
589 | 572 | if url.scheme == 'oracle': |
590 | 573 | # Django oracle/base.py strips port and fails on non-string value |
591 | 574 | if not config['PORT']: |
592 | del (config['PORT']) | |
575 | del config['PORT'] | |
593 | 576 | else: |
594 | 577 | config['PORT'] = str(config['PORT']) |
595 | 578 | |
607 | 590 | else: |
608 | 591 | config['ENGINE'] = url.scheme |
609 | 592 | |
610 | if config['ENGINE'] in Env.DB_SCHEMES: | |
611 | config['ENGINE'] = Env.DB_SCHEMES[config['ENGINE']] | |
593 | if config['ENGINE'] in cls.DB_SCHEMES: | |
594 | config['ENGINE'] = cls.DB_SCHEMES[config['ENGINE']] | |
612 | 595 | |
613 | 596 | if not config.get('ENGINE', False): |
614 | 597 | warnings.warn("Engine not recognized from url: {}".format(config)) |
630 | 613 | if not isinstance(url, cls.URL_CLASS): |
631 | 614 | if not url: |
632 | 615 | return {} |
633 | else: | |
634 | url = urlparse(url) | |
616 | url = urlparse(url) | |
635 | 617 | |
636 | 618 | if url.scheme not in cls.CACHE_SCHEMES: |
637 | 619 | raise ImproperlyConfigured( |
775 | 757 | params = {} # type: dict |
776 | 758 | if url.query: |
777 | 759 | params = parse_qs(url.query) |
778 | if 'EXCLUDED_INDEXES' in params.keys(): | |
760 | if 'EXCLUDED_INDEXES' in params: | |
779 | 761 | config['EXCLUDED_INDEXES'] \ |
780 | 762 | = params['EXCLUDED_INDEXES'][0].split(',') |
781 | if 'INCLUDE_SPELLING' in params.keys(): | |
763 | if 'INCLUDE_SPELLING' in params: | |
782 | 764 | config['INCLUDE_SPELLING'] = cls.parse_value( |
783 | 765 | params['INCLUDE_SPELLING'][0], |
784 | 766 | bool |
785 | 767 | ) |
786 | if 'BATCH_SIZE' in params.keys(): | |
768 | if 'BATCH_SIZE' in params: | |
787 | 769 | config['BATCH_SIZE'] = cls.parse_value( |
788 | 770 | params['BATCH_SIZE'][0], |
789 | 771 | int |
791 | 773 | |
792 | 774 | if url.scheme == 'simple': |
793 | 775 | return config |
794 | elif url.scheme in ['solr'] + cls.ELASTICSEARCH_FAMILY: | |
795 | if 'KWARGS' in params.keys(): | |
776 | if url.scheme in ['solr'] + cls.ELASTICSEARCH_FAMILY: | |
777 | if 'KWARGS' in params: | |
796 | 778 | config['KWARGS'] = params['KWARGS'][0] |
797 | 779 | |
798 | 780 | # remove trailing slash |
803 | 785 | config['URL'] = urlunparse( |
804 | 786 | ('http',) + url[1:2] + (path,) + ('', '', '') |
805 | 787 | ) |
806 | if 'TIMEOUT' in params.keys(): | |
788 | if 'TIMEOUT' in params: | |
807 | 789 | config['TIMEOUT'] = cls.parse_value(params['TIMEOUT'][0], int) |
808 | 790 | return config |
809 | 791 | |
820 | 802 | config['URL'] = urlunparse( |
821 | 803 | ('http',) + url[1:2] + (path,) + ('', '', '') |
822 | 804 | ) |
823 | if 'TIMEOUT' in params.keys(): | |
805 | if 'TIMEOUT' in params: | |
824 | 806 | config['TIMEOUT'] = cls.parse_value(params['TIMEOUT'][0], int) |
825 | 807 | config['INDEX_NAME'] = index |
826 | 808 | return config |
828 | 810 | config['PATH'] = '/' + path |
829 | 811 | |
830 | 812 | if url.scheme == 'whoosh': |
831 | if 'STORAGE' in params.keys(): | |
813 | if 'STORAGE' in params: | |
832 | 814 | config['STORAGE'] = params['STORAGE'][0] |
833 | if 'POST_LIMIT' in params.keys(): | |
815 | if 'POST_LIMIT' in params: | |
834 | 816 | config['POST_LIMIT'] = cls.parse_value( |
835 | 817 | params['POST_LIMIT'][0], |
836 | 818 | int |
837 | 819 | ) |
838 | 820 | elif url.scheme == 'xapian': |
839 | if 'FLAGS' in params.keys(): | |
821 | if 'FLAGS' in params: | |
840 | 822 | config['FLAGS'] = params['FLAGS'][0] |
841 | 823 | |
842 | 824 | if engine: |
845 | 827 | return config |
846 | 828 | |
847 | 829 | @classmethod |
848 | def read_env(cls, env_file=None, overwrite=False, **overrides): | |
830 | def read_env(cls, env_file=None, overwrite=False, encoding='utf8', | |
831 | **overrides): | |
849 | 832 | r"""Read a .env file into os.environ. |
850 | 833 | |
851 | 834 | If not given a path to a dotenv path, does filthy magic stack |
865 | 848 | the Django settings module from the Django project root. |
866 | 849 | :param overwrite: ``overwrite=True`` will force an overwrite of |
867 | 850 | existing environment variables. |
851 | :param encoding: The encoding to use when reading the environment file. | |
868 | 852 | :param \**overrides: Any additional keyword arguments provided directly |
869 | 853 | to read_env will be added to the environment. If the key matches an |
870 | 854 | existing environment variable, the value will be overridden. |
871 | 855 | """ |
872 | 856 | if env_file is None: |
857 | # pylint: disable=protected-access | |
873 | 858 | frame = sys._getframe() |
874 | 859 | env_file = os.path.join( |
875 | 860 | os.path.dirname(frame.f_back.f_code.co_filename), |
878 | 863 | if not os.path.exists(env_file): |
879 | 864 | logger.info( |
880 | 865 | "%s doesn't exist - if you're not configuring your " |
881 | "environment separately, create one." % env_file) | |
866 | "environment separately, create one.", env_file) | |
882 | 867 | return |
883 | 868 | |
884 | 869 | try: |
885 | 870 | if isinstance(env_file, Openable): |
886 | 871 | # Python 3.5 support (wrap path with str). |
887 | with open(str(env_file)) as f: | |
872 | with open(str(env_file), encoding=encoding) as f: | |
888 | 873 | content = f.read() |
889 | 874 | else: |
890 | 875 | with env_file as f: |
892 | 877 | except OSError: |
893 | 878 | logger.info( |
894 | 879 | "%s not found - if you're not configuring your " |
895 | "environment separately, check this." % env_file) | |
880 | "environment separately, check this.", env_file) | |
896 | 881 | return |
897 | 882 | |
898 | logger.debug('Read environment variables from: {}'.format(env_file)) | |
883 | logger.debug('Read environment variables from: %s', env_file) | |
899 | 884 | |
900 | 885 | def _keep_escaped_format_characters(match): |
901 | 886 | """Keep escaped newline/tabs in quoted strings""" |
975 | 960 | :param \**kwargs: ``**kwargs`` passed to :py:func:`open` |
976 | 961 | :rtype: typing.IO[typing.Any] |
977 | 962 | """ |
963 | # pylint: disable=unspecified-encoding | |
978 | 964 | return open(self(name), *args, **kwargs) |
979 | 965 | |
980 | 966 | @property |
982 | 968 | """Current directory for this Path""" |
983 | 969 | return self.__root__ |
984 | 970 | |
971 | # pylint: disable=keyword-arg-before-vararg | |
985 | 972 | def __init__(self, start='', *paths, **kwargs): |
986 | 973 | |
987 | 974 | super().__init__() |
1015 | 1002 | def __sub__(self, other): |
1016 | 1003 | if isinstance(other, int): |
1017 | 1004 | return self.path('../' * other) |
1018 | elif isinstance(other, str): | |
1019 | if self.__root__.endswith(other): | |
1020 | return Path(self.__root__.rstrip(other)) | |
1005 | if isinstance(other, str) and self.__root__.endswith(other): | |
1006 | return Path(self.__root__.rstrip(other)) | |
1007 | ||
1021 | 1008 | raise TypeError( |
1022 | 1009 | "unsupported operand type(s) for -: '{self}' and '{other}' " |
1023 | 1010 | "unless value of {self} ends with value of {other}".format( |
1050 | 1037 | return self.__str__() |
1051 | 1038 | |
1052 | 1039 | def rfind(self, *args, **kwargs): |
1053 | return self.__str__().rfind(*args, **kwargs) | |
1040 | """Proxy method to :py:func:`str.rfind`""" | |
1041 | return str(self).rfind(*args, **kwargs) | |
1054 | 1042 | |
1055 | 1043 | def find(self, *args, **kwargs): |
1056 | return self.__str__().find(*args, **kwargs) | |
1044 | """Proxy method to :py:func:`str.find`""" | |
1045 | return str(self).find(*args, **kwargs) | |
1057 | 1046 | |
1058 | 1047 | @staticmethod |
1059 | 1048 | def _absolute_join(base, *paths, **kwargs): |
1062 | 1051 | raise ImproperlyConfigured( |
1063 | 1052 | "Create required path: {}".format(absolute_path)) |
1064 | 1053 | return absolute_path |
1065 | ||
1066 | ||
1067 | def register_scheme(scheme): | |
1068 | for method in dir(urlparselib): | |
1069 | if method.startswith('uses_'): | |
1070 | getattr(urlparselib, method).append(scheme) | |
1071 | ||
1072 | ||
1073 | def register_schemes(schemes): | |
1074 | for scheme in schemes: | |
1075 | register_scheme(scheme) | |
1076 | ||
1077 | ||
1078 | # Register database and cache schemes in URLs. | |
1079 | register_schemes(Env.DB_SCHEMES.keys()) | |
1080 | register_schemes(Env.CACHE_SCHEMES.keys()) | |
1081 | register_schemes(Env.SEARCH_SCHEMES.keys()) | |
1082 | register_schemes(Env.EMAIL_SCHEMES.keys()) |
44 | 44 | return self.files_cache[key] |
45 | 45 | key_file = self.env.get(key + "_FILE") |
46 | 46 | if key_file: |
47 | with open(key_file) as f: | |
47 | with open(key_file, encoding='utf-8') as f: | |
48 | 48 | value = f.read() |
49 | 49 | if self.cache: |
50 | 50 | self.files_cache[key] = value |
9 | 9 | |
10 | 10 | import codecs |
11 | 11 | import re |
12 | import sys | |
13 | import warnings | |
12 | 14 | from os import path |
13 | 15 | |
14 | 16 | from setuptools import find_packages, setup |
17 | ||
18 | ||
19 | if sys.version_info < (3, 6): | |
20 | warnings.warn( | |
21 | "Support of Python < 3.6 is deprecated" | |
22 | "and will be removed in a future release.", | |
23 | DeprecationWarning | |
24 | ) | |
15 | 25 | |
16 | 26 | |
17 | 27 | def read_file(filepath): |
130 | 140 | 'Framework :: Django :: 3.1', |
131 | 141 | 'Framework :: Django :: 3.2', |
132 | 142 | 'Framework :: Django :: 4.0', |
143 | 'Framework :: Django :: 4.1', | |
133 | 144 | |
134 | 145 | 'Operating System :: OS Independent', |
135 | 146 | |
138 | 149 | |
139 | 150 | 'Programming Language :: Python', |
140 | 151 | 'Programming Language :: Python :: 3', |
141 | 'Programming Language :: Python :: 3.4', | |
142 | 152 | 'Programming Language :: Python :: 3.5', |
143 | 153 | 'Programming Language :: Python :: 3.6', |
144 | 154 | 'Programming Language :: Python :: 3.7', |
145 | 155 | 'Programming Language :: Python :: 3.8', |
146 | 156 | 'Programming Language :: Python :: 3.9', |
147 | 157 | 'Programming Language :: Python :: 3.10', |
158 | 'Programming Language :: Python :: 3.11', | |
148 | 159 | 'Programming Language :: Python :: Implementation :: CPython', |
149 | 160 | 'Programming Language :: Python :: Implementation :: PyPy', |
150 | 161 | |
216 | 227 | platforms=['any'], |
217 | 228 | include_package_data=True, |
218 | 229 | zip_safe=False, |
219 | python_requires='>=3.4,<4', | |
230 | python_requires='>=3.5,<4', | |
220 | 231 | install_requires=INSTALL_REQUIRES, |
221 | 232 | dependency_links=DEPENDENCY_LINKS, |
222 | 233 | extras_require=EXTRAS_REQUIRE, |
24 | 24 | EMAIL = 'smtps://user@domain.com:password@smtp.example.com:587' |
25 | 25 | JSON = dict(one='bar', two=2, three=33.44) |
26 | 26 | DICT = dict(foo='bar', test='on') |
27 | DICT_WITH_EQ = dict(key1='sub_key1=sub_value1', key2='value2') | |
27 | 28 | PATH = '/home/dev' |
28 | 29 | EXPORTED = 'exported var' |
29 | 30 | SAML_ATTRIBUTE_MAPPING = dict( |
66 | 67 | STR_LIST_WITH_SPACES=' foo, bar', |
67 | 68 | EMPTY_LIST='', |
68 | 69 | DICT_VAR='foo=bar,test=on', |
70 | DICT_WITH_EQ_VAR='key1=sub_key1=sub_value1,key2=value2', | |
69 | 71 | DATABASE_URL=cls.POSTGRES, |
70 | 72 | DATABASE_MYSQL_URL=cls.MYSQL, |
71 | 73 | DATABASE_MYSQL_GIS_URL=cls.MYSQLGIS, |
0 | 0 | # This file is part of the django-environ. |
1 | 1 | # |
2 | # Copyright (c) 2021, Serghei Iakovlev <egrep@protonmail.ch> | |
2 | # Copyright (c) 2021-2022, Serghei Iakovlev <egrep@protonmail.ch> | |
3 | 3 | # Copyright (c) 2013-2021, Daniele Faraglia <daniele.faraglia@gmail.com> |
4 | 4 | # |
5 | 5 | # For the full copyright and license information, please view |
11 | 11 | |
12 | 12 | import environ.compat |
13 | 13 | from environ import Env |
14 | from environ.compat import PYMEMCACHE_DRIVER, REDIS_DRIVER, ImproperlyConfigured | |
14 | from environ.compat import ( | |
15 | ImproperlyConfigured, | |
16 | PYMEMCACHE_DRIVER, | |
17 | REDIS_DRIVER, | |
18 | ) | |
15 | 19 | |
16 | 20 | |
17 | 21 | def test_base_options_parsing(): |
53 | 57 | ('rediscache://host1:6379,host2:6379,host3:9999/1', REDIS_DRIVER, |
54 | 58 | ['redis://host1:6379/1', 'redis://host2:6379/1', |
55 | 59 | 'redis://host3:9999/1']), |
56 | ('rediscache:///path/to/socket:1', 'django_redis.cache.RedisCache', | |
60 | ('rediscache:///path/to/socket:1', REDIS_DRIVER, | |
57 | 61 | 'unix:///path/to/socket:1'), |
58 | 62 | ('memcache:///tmp/memcached.sock', |
59 | 63 | 'django.core.cache.backends.memcached.MemcachedCache', |
111 | 115 | assert driver == new if pymemcache_installed else old |
112 | 116 | |
113 | 117 | |
118 | @pytest.mark.parametrize('django_version', ((4, 0), (3, 2), None)) | |
119 | @pytest.mark.parametrize('redis_cache_installed', (True, False)) | |
120 | def test_rediscache_compat(django_version, redis_cache_installed): | |
121 | django_new = 'django.core.cache.backends.redis.RedisCache' | |
122 | redis_cache = 'redis_cache.RedisCache' | |
123 | django_old = 'django_redis.cache.RedisCache' | |
124 | ||
125 | with mock.patch.object(environ.compat, 'DJANGO_VERSION', django_version): | |
126 | with mock.patch('environ.compat.find_loader') as mock_find_loader: | |
127 | mock_find_loader.return_value = redis_cache_installed | |
128 | driver = environ.compat.choose_rediscache_driver() | |
129 | if django_version and django_version >= (4, 0): | |
130 | assert driver == django_new | |
131 | else: | |
132 | assert driver == redis_cache if redis_cache_installed else django_old | |
133 | ||
134 | ||
114 | 135 | def test_redis_parsing(): |
115 | 136 | url = ('rediscache://127.0.0.1:6379/1?client_class=' |
116 | 137 | 'django_redis.client.DefaultClient&password=secret') |
185 | 206 | env = Env() |
186 | 207 | |
187 | 208 | result = env.cache() |
188 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
209 | assert result['BACKEND'] == REDIS_DRIVER | |
189 | 210 | assert result['LOCATION'] == url |
190 | 211 | |
191 | 212 | result = env.cache_url_config(url) |
192 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
213 | assert result['BACKEND'] == REDIS_DRIVER | |
193 | 214 | assert result['LOCATION'] == url |
194 | 215 | |
195 | 216 | url = 'rediss://enigma:sec{}ret@ondigitalocean.com:25061/2'.format(chars) |
197 | 218 | env = Env() |
198 | 219 | |
199 | 220 | result = env.cache() |
200 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
221 | assert result['BACKEND'] == REDIS_DRIVER | |
201 | 222 | assert result['LOCATION'] == url |
202 | 223 | |
203 | 224 | result = env.cache_url_config(url) |
204 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
225 | assert result['BACKEND'] == REDIS_DRIVER | |
205 | 226 | assert result['LOCATION'] == url |
206 | 227 | |
207 | 228 | url = 'rediss://enigma:{}secret@ondigitalocean.com:25061/2'.format(chars) |
209 | 230 | env = Env() |
210 | 231 | |
211 | 232 | result = env.cache() |
212 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
233 | assert result['BACKEND'] == REDIS_DRIVER | |
213 | 234 | assert result['LOCATION'] == url |
214 | 235 | |
215 | 236 | result = env.cache_url_config(url) |
216 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
237 | assert result['BACKEND'] == REDIS_DRIVER | |
217 | 238 | assert result['LOCATION'] == url |
218 | 239 | |
219 | 240 | |
229 | 250 | env = Env() |
230 | 251 | |
231 | 252 | result = env.cache() |
232 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
253 | assert result['BACKEND'] == REDIS_DRIVER | |
233 | 254 | assert result['LOCATION'] == url |
234 | 255 | |
235 | 256 | url = 'rediss://enigma:sec{}ret@ondigitalocean.com:25061/2'.format(chars) |
237 | 258 | env = Env() |
238 | 259 | |
239 | 260 | result = env.cache() |
240 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
261 | assert result['BACKEND'] == REDIS_DRIVER | |
241 | 262 | assert result['LOCATION'] == url |
242 | 263 | |
243 | 264 | url = 'rediss://enigma:{}secret@ondigitalocean.com:25061/2'.format(chars) |
245 | 266 | env = Env() |
246 | 267 | |
247 | 268 | result = env.cache() |
248 | assert result['BACKEND'] == 'django_redis.cache.RedisCache' | |
269 | assert result['BACKEND'] == REDIS_DRIVER | |
249 | 270 | assert result['LOCATION'] == url |
250 | 271 | |
251 | 272 |
0 | 0 | # This file is part of the django-environ. |
1 | 1 | # |
2 | # Copyright (c) 2021, Serghei Iakovlev <egrep@protonmail.ch> | |
2 | # Copyright (c) 2021-2022, Serghei Iakovlev <egrep@protonmail.ch> | |
3 | 3 | # Copyright (c) 2013-2021, Daniele Faraglia <daniele.faraglia@gmail.com> |
4 | 4 | # |
5 | 5 | # For the full copyright and license information, please view |
167 | 167 | |
168 | 168 | if host == 'reconnect.com': |
169 | 169 | assert config['OPTIONS'] == {'reconnect': 'true'} |
170 | ||
171 | 170 | |
172 | 171 | |
173 | 172 | def test_postgres_complex_db_name_parsing(): |
7 | 7 | |
8 | 8 | import os |
9 | 9 | from urllib.parse import quote |
10 | from warnings import catch_warnings | |
11 | 10 | |
12 | 11 | import pytest |
13 | 12 | |
14 | 13 | from environ import Env, Path |
15 | from environ.compat import ImproperlyConfigured, DJANGO_POSTGRES | |
14 | from environ.compat import ( | |
15 | DJANGO_POSTGRES, | |
16 | ImproperlyConfigured, | |
17 | REDIS_DRIVER, | |
18 | ) | |
16 | 19 | from .asserts import assert_type_and_value |
17 | 20 | from .fixtures import FakeEnv |
18 | 21 | |
69 | 72 | if not multiline: |
70 | 73 | assert self.env(var) == val |
71 | 74 | assert self.env.str(var, multiline=multiline) == val |
72 | ||
73 | def test_unicode(self, recwarn): | |
74 | actual = self.env.unicode('CYRILLIC_VAR', default='фуубар') | |
75 | expected = self.env.str('CYRILLIC_VAR', default='фуубар') | |
76 | ||
77 | assert actual == expected | |
78 | assert len(recwarn) == 1 | |
79 | w = recwarn.pop(DeprecationWarning) | |
80 | assert issubclass(w.category, DeprecationWarning) | |
81 | assert str(w.message) == '`%s.unicode` is deprecated, use `%s.str` instead' %( | |
82 | self.env.__class__.__name__, | |
83 | self.env.__class__.__name__, | |
84 | ) | |
85 | assert w.filename | |
86 | assert w.lineno | |
87 | 75 | |
88 | 76 | @pytest.mark.parametrize( |
89 | 77 | 'var,val,default', |
167 | 155 | |
168 | 156 | def test_mix_tuple_issue_387(self): |
169 | 157 | """Cast a tuple of mixed types. |
170 | ||
158 | ||
171 | 159 | Casts a string like "(42,Test)" to a tuple like (42, 'Test'). |
172 | 160 | See: https://github.com/joke2k/django-environ/issues/387 for details.""" |
173 | caster = lambda v: int(v) if v.isdigit() else v.strip() | |
174 | cast = lambda t: tuple(map(caster, [c for c in t.strip('()').split(',')])) | |
175 | assert_type_and_value(tuple, (42, 'Test'), self.env( 'MIX_TUPLE', default=(0, ''), cast=cast)) | |
161 | assert_type_and_value( | |
162 | tuple, | |
163 | (42, 'Test'), | |
164 | self.env( | |
165 | 'MIX_TUPLE', | |
166 | default=(0, ''), | |
167 | cast=lambda t: tuple( | |
168 | map( | |
169 | lambda v: int(v) if v.isdigit() else v.strip(), | |
170 | [c for c in t.strip('()').split(',')] | |
171 | ) | |
172 | ), | |
173 | ) | |
174 | ) | |
176 | 175 | |
177 | 176 | def test_str_list_with_spaces(self): |
178 | 177 | assert_type_and_value(list, [' foo', ' bar'], |
185 | 184 | |
186 | 185 | def test_dict_value(self): |
187 | 186 | assert_type_and_value(dict, FakeEnv.DICT, self.env.dict('DICT_VAR')) |
187 | assert_type_and_value(dict, FakeEnv.DICT_WITH_EQ, self.env.dict('DICT_WITH_EQ_VAR')) | |
188 | 188 | |
189 | 189 | def test_complex_dict_value(self): |
190 | 190 | assert_type_and_value( |
225 | 225 | assert url.__class__ == self.env.URL_CLASS |
226 | 226 | assert url.geturl() == FakeEnv.URL |
227 | 227 | assert self.env.url('OTHER_URL', default=None) is None |
228 | ||
229 | def test_url_empty_string_default_value(self): | |
230 | unset_var_name = 'VARIABLE_NOT_SET_IN_ENVIRONMENT' | |
231 | assert unset_var_name not in os.environ | |
232 | url = self.env.url(unset_var_name, '') | |
233 | assert url.__class__ == self.env.URL_CLASS | |
234 | assert url.geturl() == '' | |
228 | 235 | |
229 | 236 | def test_url_encoded_parts(self): |
230 | 237 | password_with_unquoted_characters = "#password" |
290 | 297 | (Env.DEFAULT_CACHE_ENV, |
291 | 298 | 'django.core.cache.backends.memcached.MemcachedCache', |
292 | 299 | '127.0.0.1:11211', None), |
293 | ('CACHE_REDIS', 'django_redis.cache.RedisCache', | |
300 | ('CACHE_REDIS', REDIS_DRIVER, | |
294 | 301 | 'redis://127.0.0.1:6379/1', |
295 | 302 | {'CLIENT_CLASS': 'django_redis.client.DefaultClient', |
296 | 303 | 'PASSWORD': 'secret'}), |
0 | 0 | DICT_VAR=foo=bar,test=on |
1 | DICT_WITH_EQ_VAR=key1=sub_key1=sub_value1,key2=value2 | |
1 | 2 | |
2 | 3 | # Database variables |
3 | 4 | DATABASE_MYSQL_URL=mysql://bea6eb0:69772142@us-cdbr-east.cleardb.com/heroku_97681?reconnect=true |
0 | 0 | # This file is part of the django-environ. |
1 | 1 | # |
2 | # Copyright (c) 2021, Serghei Iakovlev <egrep@protonmail.ch> | |
2 | # Copyright (c) 2021-2022, Serghei Iakovlev <egrep@protonmail.ch> | |
3 | 3 | # Copyright (c) 2013-2021, Daniele Faraglia <daniele.faraglia@gmail.com> |
4 | 4 | # |
5 | 5 | # For the full copyright and license information, please view |
9 | 9 | import tempfile |
10 | 10 | from contextlib import contextmanager |
11 | 11 | |
12 | import pytest | |
13 | ||
12 | 14 | import environ |
13 | import pytest | |
14 | 15 | |
15 | 16 | |
16 | 17 | @contextmanager |
0 | 0 | # This file is part of the django-environ. |
1 | 1 | # |
2 | # Copyright (c) 2021, Serghei Iakovlev <egrep@protonmail.ch> | |
2 | # Copyright (c) 2021-2022, Serghei Iakovlev <egrep@protonmail.ch> | |
3 | 3 | # Copyright (c) 2013-2021, Daniele Faraglia <daniele.faraglia@gmail.com> |
4 | 4 | # |
5 | 5 | # For the full copyright and license information, please view |
6 | 6 | # the LICENSE.txt file that was distributed with this source code. |
7 | 7 | |
8 | 8 | import os |
9 | import sys | |
10 | ||
9 | 11 | import pytest |
10 | import sys | |
12 | ||
11 | 13 | |
12 | 14 | from environ import Path |
13 | 15 | from environ.compat import ImproperlyConfigured |
69 | 71 | assert '/home' == Path('/home') |
70 | 72 | |
71 | 73 | assert Path('/home') != '/usr' |
74 | ||
72 | 75 | |
73 | 76 | def test_sum(): |
74 | 77 | """Make sure Path correct handle __add__.""" |
0 | 0 | # This file is part of the django-environ. |
1 | 1 | # |
2 | # Copyright (c) 2021, Serghei Iakovlev <egrep@protonmail.ch> | |
2 | # Copyright (c) 2021-2022, Serghei Iakovlev <egrep@protonmail.ch> | |
3 | 3 | # Copyright (c) 2013-2021, Daniele Faraglia <daniele.faraglia@gmail.com> |
4 | 4 | # |
5 | 5 | # For the full copyright and license information, please view |
6 | 6 | # the LICENSE.txt file that was distributed with this source code. |
7 | 7 | |
8 | 8 | import pytest |
9 | ||
9 | 10 | from environ.environ import _cast, _cast_urlstr |
10 | 11 | |
11 | 12 | |
19 | 20 | |
20 | 21 | See https://github.com/joke2k/django-environ/issues/200 for details.""" |
21 | 22 | assert _cast(literal) == literal |
23 | ||
22 | 24 | |
23 | 25 | @pytest.mark.parametrize( |
24 | 26 | "quoted_url_str,expected_unquoted_str", |
17 | 17 | docs |
18 | 18 | lint |
19 | 19 | manifest |
20 | py{35,36,37,38,39,310}-django{111,22} | |
21 | py{36,37,38,39,310}-django{30,31,32} | |
22 | py{38,39,310}-django{40} | |
20 | py{35,36,37,38,39,310,311}-django{111,22} | |
21 | py{36,37,38,39,310,311}-django{30,31,32} | |
22 | py{38,39,310,311}-django{40,41} | |
23 | 23 | pypy-django{111,22,30,31,32} |
24 | 24 | |
25 | 25 | [gh-actions] |
30 | 30 | 3.8: py38 |
31 | 31 | 3.9: py39 |
32 | 32 | 3.10: py310 |
33 | 3.11: py311 | |
33 | 34 | pypy-3.7: pypy |
34 | 35 | |
35 | 36 | [testenv] |
42 | 43 | django31: Django>=3.1,<3.2 |
43 | 44 | django32: Django>=3.2,<3.3 |
44 | 45 | django40: Django>=4.0,<4.1 |
46 | django41: Django>=4.1,<4.2 | |
45 | 47 | commands_pre = |
46 | 48 | python -m pip install --upgrade pip |
47 | 49 | python -m pip install . |
66 | 68 | flake8 |
67 | 69 | flake8-blind-except |
68 | 70 | flake8-import-order |
71 | pylint | |
69 | 72 | commands_pre = |
70 | 73 | python -m pip install --upgrade pip |
71 | 74 | python -m pip install . |
72 | commands = flake8 environ setup.py | |
75 | commands = | |
76 | flake8 environ setup.py | |
77 | # Format ("f") strings have not been introduced before Python 3.6, | |
78 | # thus disable "consider-using-f-string" at this moment. | |
79 | pylint \ | |
80 | --logging-format-style=old \ | |
81 | --good-names-rgxs=m[0-9],f,v \ | |
82 | --disable=too-few-public-methods \ | |
83 | --disable=import-error \ | |
84 | --disable=unused-import \ | |
85 | --disable=consider-using-f-string \ | |
86 | --disable=too-many-locals \ | |
87 | --disable=too-many-branches \ | |
88 | --disable=too-many-public-methods \ | |
89 | --disable=too-many-lines \ | |
90 | environ | |
73 | 91 | |
74 | 92 | [testenv:linkcheck] |
75 | 93 | description = Check external links in the package documentation |