-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Improvement for Parser.addini to facilite parsing of 'int' and 'float' values #13193
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.
Thanks @harmin-parra for the PR!
Left some tweaks to the docs, otherwise LGTM!
Co-authored-by: Bruno Oliveira <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
Co-authored-by: Bruno Oliveira <[email protected]>
There are still some mypy errors that I have no idea how to resolve |
for more information, see https://pre-commit.ci
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.
Awesome, thanks!
I will leave it open for a few days to give others a chance to review.
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.
I think all those casts in config/__init__.py
are incorrect and are hiding bugs.
A pyproject.toml with:
[tool.pytest.ini_options]
int_value = [3]
now causes
elif type == "int":
# value = cast(str, value)
try:
> return int(value)
^^^^^^^^^^
E TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'
I suspect (but haven't tried) that passing an int/float for a paths
option will fail in a similar way.
We should probably do some additional validation that the input-type is correct, and raise an exception including the option name if not.
@The-Compiler I agree. Currently it is only catching |
That would still need a if not isinstance(value, (str, int)):
raise TypeError(f"Expected str or int for option {name} of type integer, but got: {value!r} ({type(value)})") or so would:
|
Sounds good. |
Implements #11381
parsing of
int
andfloat
configuration values from the ini files has been improved