Skip to content

Commit

Permalink
included suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
lvanderree committed Jul 6, 2023
1 parent fc5b410 commit 09a965a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Added
`#463 <https://github.com/joke2k/django-environ/pull/463>`_.
- Added variable expansion
`#468 <https://github.com/joke2k/django-environ/pull/468>`_.
- Added capability to handle comments after #, after quoted values, like `KEY= 'part1 # part2' # comment`
- Added capability to handle comments after #, after quoted values, like ``KEY= 'part1 # part2' # comment``
`#475 <https://github.com/joke2k/django-environ/pull/475>`_.

Changed
Expand Down
8 changes: 4 additions & 4 deletions environ/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,14 +970,14 @@ def _keep_escaped_format_characters(match):
m1 = re.match(r'\A(?:export )?([A-Za-z_0-9]+)=(.*)\Z', line)
if m1:
key, val = m1.group(1), m1.group(2)
# search for value within quotes,
# ignore comments after # (outside quotes)
# Look for value in quotes, ignore post-# comments
# (outside quotes)
m2 = re.match(r"\A\s*'(?<!\\)(.*)'\s*(#.*\s*)?\Z", val)
if m2:
val = m2.group(1)
else:
# if no quotes, search for value,
# ignore comments after first #
# For no quotes, find value, ignore comments
# after the first #
m2a = re.match(r"\A(.*?)(#.*\s*)?\Z", val)
if m2a:
val = m2a.group(1)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ def test_str_list_with_spaces(self):
self.env('STR_LIST_WITH_SPACES', cast=[str]))
assert_type_and_value(list, [' foo', ' spaces'],
self.env.list('STR_LIST_WITH_SPACES'))
# assert_type_and_value(list, [' foo', ' quoted'],
# self.env.list('STR_LIST_WITH_SPACES_QUOTED')
# ) # TODO: fix this

def test_empty_list(self):
assert_type_and_value(list, [], self.env('EMPTY_LIST', cast=[int]))
Expand Down

0 comments on commit 09a965a

Please sign in to comment.