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

Environment variables overriding defaults within a subclass #31

Closed
Dandb79 opened this issue Nov 20, 2019 · 2 comments
Closed

Environment variables overriding defaults within a subclass #31

Dandb79 opened this issue Nov 20, 2019 · 2 comments

Comments

@Dandb79
Copy link

Dandb79 commented Nov 20, 2019

Consider the following example:

from vyper import Vyper  
from os import environ as env  
env['CLASS.KEY2'] = 'newval2'  
v = Vyper(key_delimiter='.')  
v.set_default('class.key1', 'val1')  
v.set_default('class.key2', 'val2')  
v.set_default('class.key3', 'val3')  
v.bind_env('class.key1')  
v.bind_env('class.key2')  
v.bind_env('class.key3')  
print(v.get('class.key1'))  

The expected behaviour would be to output val1 but instead the following stack trace occurs:

Traceback (most recent call last):
  File "test.py", line 16, in <module>
    print(v.get('class.key1'))
  File "/home/dandb/anaconda3/lib/python3.7/site-packages/vyper/vyper.py", line 186, in get
    val = self._find(lowercase_key)
  File "/home/dandb/anaconda3/lib/python3.7/site-packages/vyper/vyper.py", line 409, in _find
    source = self._find(path[0])
  File "/home/dandb/anaconda3/lib/python3.7/site-packages/vyper/vyper.py", line 382, in _find
    self._set_insensitive(item["final_key"], val, temp)
  File "/home/dandb/anaconda3/lib/python3.7/site-packages/vyper/vyper.py", line 324, in _set_insensitive
    real_key = self._find_real_key(key, source)
  File "/home/dandb/anaconda3/lib/python3.7/site-packages/vyper/vyper.py", line 316, in _find_real_key
    (real for real in source.keys() if real.lower() == key.lower()), None
AttributeError: 'NoneType' object has no attribute 'keys'
@Dandb79
Copy link
Author

Dandb79 commented Nov 28, 2019

Hi there,

Any updates regarding this issue or my solution from your end?

@alexferl
Copy link
Owner

alexferl commented Mar 25, 2020

Fixed in v0.6.2, thanks for the PR!

tioxy added a commit to bataclanofficial/botaclan-archives that referenced this issue May 15, 2020
Generate automatically environment variables instead of manual binding.
This fixes a random bug described in:
- alexferl/vyper#37
- alexferl/vyper#31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants