Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add interpolate argument to avoid resolving proxied values." #486

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ All notable changes to this project will be documented in this file.
The format is inspired by `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.

`v0.12.0`_ - 00-Unreleased-2023
-------------------------------

`v0.11.1`_ - 30-August-2023
---------------------------
Fixed
+++++
- Revert "Add interpolate argument to avoid resolving proxied values." feature
due to `#485 <https://github.com/joke2k/django-environ/issues/485>`_.


`v0.11.0`_ - 30-August-2023
-------------------------------
---------------------------
Added
+++++
- Added support for Django 4.2
Expand Down Expand Up @@ -377,7 +380,7 @@ Added
- Initial release.


.. _v0.12.0: https://github.com/joke2k/django-environ/compare/v0.10.0...develop
.. _v0.11.1: https://github.com/joke2k/django-environ/compare/v0.11.0...v0.11.1
.. _v0.11.0: https://github.com/joke2k/django-environ/compare/v0.10.0...v0.11.0
.. _v0.10.0: https://github.com/joke2k/django-environ/compare/v0.9.0...v0.10.0
.. _v0.9.0: https://github.com/joke2k/django-environ/compare/v0.8.1...v0.9.0
Expand Down
2 changes: 1 addition & 1 deletion docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Proxy value
===========

Values that being with a ``$`` may be interpolated. Pass ``interpolate=True`` to
``environ.Env()`` to enable this feature (``True`` by default):
``environ.Env()`` to enable this feature:

.. code-block:: python

Expand Down
6 changes: 2 additions & 4 deletions environ/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,11 @@ class Env:
VAR = re.compile(r'(?<!\\)\$\{?(?P<name>[A-Z_][0-9A-Z_]*)}?',
re.IGNORECASE)

def __init__(self, interpolate=True, **scheme):
def __init__(self, **scheme):
self._local = threading.local()
self.smart_cast = True
self.escape_proxy = False
self.prefix = ""
self.interpolate = interpolate
self.scheme = scheme

def __call__(self, var, cast=None, default=NOTSET, parse_default=False):
Expand Down Expand Up @@ -426,8 +425,7 @@ def _get_value(self, var_name, cast=None, default=NOTSET,
value = default

# Expand variables
if self.interpolate and isinstance(value, (bytes, str)) \
and var_name not in NOT_EXPANDED:
if isinstance(value, (bytes, str)) and var_name not in NOT_EXPANDED:
def repl(match_):
return self.get_value(
match_.group('name'), cast=cast, default=default,
Expand Down
4 changes: 0 additions & 4 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ def test_bool_true(self, value, variable):
def test_proxied_value(self):
assert self.env('PROXIED_VAR') == 'bar'

def test_not_interpolated_proxied_value(self):
env = Env(interpolate=False)
assert env('PROXIED_VAR') == '$STR_VAR'

def test_escaped_dollar_sign(self):
self.env.escape_proxy = True
assert self.env('ESCAPED_VAR') == '$baz'
Expand Down