Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Allow explicit default with null value #38

Closed
wants to merge 10 commits into from

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Feb 25, 2018

This fix readthedocs/readthedocs.org#2813

  • Test case
  • Solution

@stsewd
Copy link
Member Author

stsewd commented Feb 25, 2018

For now I'm only checking for the requirements_file default key, should I check for all defaults?

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

I left just a comment that a test that can be added to cover the a missing case and it will be ready to merge from my point of view.

config = parse(buf)
assert config[0]['base'] is None


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a good addition here would be this test also:

def test_parse_empty_value():
    buf = StringIO(u'base: ""')
    config = parse(buf)
    assert config[0]['base'] is ''

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I just noted a piece that could stick around for removal in a separate PR.

@@ -15,7 +15,6 @@
from .config import PYTHON_INVALID
from .validation import INVALID_BOOL
from .validation import INVALID_CHOICE
from .validation import INVALID_DIRECTORY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this line for now, in case we have some side effects from removing a line like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@stsewd stsewd force-pushed the allow-explicit-default-null branch from e89c7e1 to b8c68be Compare March 6, 2018 17:23
@humitos
Copy link
Member

humitos commented Apr 18, 2018

I think this PR is ready to be merged.

For now I'm only checking for the requirements_file default key, should I check for all defaults?

I suppose we should look for a general solution for this instead of repeat something like this for every field:

        if 'field' not in self.raw_config:
            return None
 
        field = self.raw_config['field']
        if field is None:
            return None

What do you think?

@stsewd
Copy link
Member Author

stsewd commented Apr 18, 2018

@humitos I was thinking of that, but if you look closely, always there are some additional checks before the second step, and at the end, we only will save 1 line of code per method.

@stsewd
Copy link
Member Author

stsewd commented May 10, 2018

I forgot to delete one line on the merge 🤦‍♂️

@agjohnson
Copy link
Contributor

@stsewd shall we do a PR into rtd core for this as well?

@stsewd
Copy link
Member Author

stsewd commented Jun 19, 2018

@agjohnson yeah!

@agjohnson
Copy link
Contributor

Cool. Setting to blocking for now, we'll revisit this after.

@agjohnson agjohnson added the Status: blocked Issue is blocked on another issue label Jun 19, 2018
stsewd added a commit to stsewd/readthedocs.org that referenced this pull request Aug 2, 2018
@stsewd
Copy link
Member Author

stsewd commented Aug 2, 2018

This is ported in readthedocs/readthedocs.org#4461

@stsewd stsewd closed this Aug 2, 2018
@stsewd stsewd deleted the allow-explicit-default-null branch August 2, 2018 18:39
agjohnson pushed a commit to readthedocs/readthedocs.org that referenced this pull request Aug 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Status: blocked Issue is blocked on another issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error "expected string" for None in YAML config
3 participants