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

params: Use ast.literal_eval for python params. #6954

Merged
merged 1 commit into from
Nov 15, 2021

Conversation

daavoo
Copy link
Contributor

@daavoo daavoo commented Nov 10, 2021

Add unit tests for parse_py

Closes #6953

dvc.org P.R: iterative/dvc.org#3014

@daavoo daavoo added bugfix fixes bug A: templating Related to the templating feature labels Nov 10, 2021
@daavoo daavoo self-assigned this Nov 10, 2021
@daavoo daavoo requested a review from a team as a code owner November 10, 2021 14:10
@daavoo daavoo requested a review from karajan1001 November 10, 2021 14:10
@daavoo daavoo force-pushed the use-literal-eval-python-params branch from 71a4deb to 850282c Compare November 10, 2021 14:17
@efiop
Copy link
Contributor

efiop commented Nov 10, 2021

@aandrusenko @skshetry (from #4456) would you mind taking a look, please?

@aandrusenko
Copy link
Contributor

I have no comments

@@ -0,0 +1,45 @@
import pytest
Copy link
Contributor

Choose a reason for hiding this comment

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

The code part LGTM.

ast.literal_eval are quite stable. I don't consider it to be worthy to do a detailed test on it. But here the tests involve collections and sequences. I just wondered that we don't test them in previous?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We test them here:

https://github.com/iterative/dvc/blob/master/tests/unit/dependency/test_params.py#L114

I went for a separate unit test as that one involves ParamsDependency and Stage in the mix.

I could remove this file and just add a test case for the UNARY_OP in the file linked above.

Copy link
Member

Choose a reason for hiding this comment

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

I don't consider it to be worthy to do a detailed test on it.

It's not testing ast.literal_eval, it's testing that we are converting assignment statement into a key-value pair correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't consider it to be worthy to do a detailed test on it.

It's not testing ast.literal_eval, it's testing that we are converting assignment statement into a key-value pair correctly.

Yes, I know that But here the tests involve collections and sequences. I just wondered that we don't test them in previous?

@karajan1001
Copy link
Contributor

@Mergifyio rebase

Add unit tests for `parse_py`

Closes  #6953
@mergify
Copy link
Contributor

mergify bot commented Nov 15, 2021

rebase

βœ… Branch has been successfully rebased

@skshetry skshetry force-pushed the use-literal-eval-python-params branch from 850282c to 43b46d4 Compare November 15, 2021 10:10
@skshetry skshetry removed the A: templating Related to the templating feature label Nov 15, 2021
@efiop efiop merged commit 7df6090 into master Nov 15, 2021
@efiop efiop deleted the use-literal-eval-python-params branch November 15, 2021 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix fixes bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Negative numbers from a Python file are not recognized as parameters
5 participants