default seems broken
See original GitHub issueHi there,
I’ve just updated from 0.4.4 to 0.4.5 and noticed a few unexpected behaviours with default. Presumably they relate to the casting changes that were introduced recently?
# the key is in my env
In [3]: env('GOOGLE_ANALYTICS_KEY')
Out[3]: 'UA-123456-78'
# I should have used a string as default here
# but I would still expect these to return my key instead of False
In [4]: env('GOOGLE_ANALYTICS_KEY', default=False)
Out[4]: False
In [7]: env('GOOGLE_ANALYTICS_KEY', default=True)
Out[7]: False
# these ones work as expected
In [5]: env('GOOGLE_ANALYTICS_KEY', default='')
Out[5]: 'UA-123456-78'
In [6]: env('GOOGLE_ANALYTICS_KEY', default=None)
Out[6]: 'UA-123456-78'
Cheers, Matthieu
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Default Windows Applications Broken - Microsoft Community
Whenever I try to open a Windows default app (photos, calculator, xbox game bar, microsoft store, etc.) it outputs the following error:.
Read more >Restore Default View seems to be broken with floating windows
Hi,. i am used to using my IDE on two screens, wich is not entirely possible with rider, as far as I am...
Read more >Theme is broken, keep reverting to default theme
I checked your site and it seems the current theme isn't Neve, it's Twenty Twenty One. The issue could be caused by some...
Read more >apt package manager seems broken : r/pop_os - Reddit
When I try to install a new package on my Pop system, I get the following error: ❯ sudo apt install cheese Reading...
Read more >Broken by default: why you should avoid most Dockerfile ...
A broken Docker image can lead to production outages, and building best-practices images is a lot harder than it seems. So don't just...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have been taking a look at this and I cannot see any benefit of this smart casting from default type.
To have a variable that normally is supposed to contain for example an int but in case of no definition from the env you want to explicitly set it to None or False is something common, with the new version this is not possible anymore, you are killing the dynamic typing Python offers.
If you want to force type casting for a specific variable you can currently do it like this:
this is ok, is working fine, but if you don’t specify any type casting I think it shouldn’t do it for you because is a feature.
Why not revert this smart cast changes?
Same for me. Avoid using python True or False with the default parameter.