-
Notifications
You must be signed in to change notification settings - Fork 573
Rename environment.get_value_string()
to get_value_raw()
.
#4132
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Happy to land this when you are.
27e963b
to
dba7d7b
Compare
Thanks for the review! I've rebased and made the type annotation more precise, to avoid errors like: foo = environment.get_value_raw('foo', '')
bar = foo.split(',') # type checker complains `foo` might be None |
a714059
to
f4df493
Compare
This pull request has not had any activity for 60 days and will be automatically closed in two weeks |
5 similar comments
This pull request has not had any activity for 60 days and will be automatically closed in two weeks |
This pull request has not had any activity for 60 days and will be automatically closed in two weeks |
This pull request has not had any activity for 60 days and will be automatically closed in two weeks |
This pull request has not had any activity for 60 days and will be automatically closed in two weeks |
This pull request has not had any activity for 60 days and will be automatically closed in two weeks |
This is a prelude to fixing type errors in
environment.py
.One of the big sources of type errors so far has been the fact that
environment.get_value()
is ~untyped. Many places in the codebase assume that it returns e.g. a string, or an int. We can introduceget_value_int()
for example for ints that checks at runtime that the environment variable evaluated to an int, and use that instead where applicable to appease thetype checker (and surface errors earlier at runtime).
There is a need for a
get_value_string()
that tries to evaluate environment variable contents, i.e. supports quoted values. Many variables are expected to be strings, yet the pervasive use ofenvironment.get_value()
andenvironment.set_value()
means it is hard to tell whether they are sometimes quoted or not.This PR renames the current
get_value_string()
function to make space for a futureget_value_string()
that evaluates variables.