Repository: joke2k/django-environ

Issue:
Support for SOME_VAR=(int, None)?
Is there a way to tell environ that `SOME_VAR=` in an env file is fine, and should lead to SOME_VAR being assigned the pythonic `None` when using the `SOME_VAR=(int, None)` format?

Discussion:
mehdy: @sergeyklay ready for review.
sergeyklay: @mehdy Could you please update change log?
coveralls: 
[![Coverage Status](https://coveralls.io/builds/43303929/badge)](https://coveralls.io/builds/43303929)

Coverage increased (+0.02%) to 90.927% when pulling **d9581fa6234b6400ef9e25219d8232dd43a68d03 on mehdy:default-none** into **a8871d0199d250a8adefe77109ee2735ece843a5 on joke2k:main**.

sergeyklay: @mehdy Please note, I changed the base branch from `main`  to `develop`

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 47d9673..c46d3ff 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -16,6 +16,8 @@ Added
 - Added option to override existing variables with ``read_env``
   `#103 <https://github.com/joke2k/django-environ/issues/103>`_,
   `#249 <https://github.com/joke2k/django-environ/issues/249>`_.
+- Added support for empty var with None default value
+  `#209 <https://github.com/joke2k/django-environ/issues/209>`_.
 
 
 Fixed
diff --git a/environ/environ.py b/environ/environ.py
index b678096..7cb2040 100644
--- a/environ/environ.py
+++ b/environ/environ.py
@@ -375,6 +375,8 @@ class Env:
                     not isinstance(default, NoValue):
                 cast = type(default)
 
+        value = None if default is None and value == '' else value
+
         if value != default or (parse_default and value):
             value = self.parse_value(value, cast)
 


Test patch:
diff --git a/tests/test_env.py b/tests/test_env.py
index acd8dc4..55147fb 100644
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -86,6 +86,7 @@ class TestEnv:
 
     def test_int_with_none_default(self):
         assert self.env('NOT_PRESENT_VAR', cast=int, default=None) is None
+        assert self.env('EMPTY_INT_VAR', cast=int, default=None) is None
 
     @pytest.mark.parametrize(
         'value,variable',
diff --git a/tests/test_env.txt b/tests/test_env.txt
index befeed7..a179a48 100644
--- a/tests/test_env.txt
+++ b/tests/test_env.txt
@@ -29,6 +29,7 @@ FLOAT_STRANGE_VAR2=123.420.333,3
 FLOAT_NEGATIVE_VAR=-1.0
 PROXIED_VAR=$STR_VAR
 EMPTY_LIST=
+EMPTY_INT_VAR=
 INT_VAR=42
 STR_LIST_WITH_SPACES= foo,  bar
 STR_VAR=bar