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

fixed toml parser ignoring style #156

Merged
merged 16 commits into from
Sep 10, 2022

Conversation

jspaezp
Copy link
Contributor

@jspaezp jspaezp commented Sep 7, 2022

Closes #155

@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

Merging #156 (f4ee706) into main (c749fc6) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #156   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines          582       589    +7     
=========================================
+ Hits           582       589    +7     
Impacted Files Coverage Δ
...ydocstringformatter/_configuration/toml_parsing.py 100.00% <100.00%> (ø)

@Pierre-Sassoulas Pierre-Sassoulas added the bug Something isn't working label Sep 7, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 0.7.3 milestone Sep 7, 2022
Copy link
Collaborator

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Thank you for opening a pull request. Could you add covering tests, please ?

@jspaezp
Copy link
Contributor Author

jspaezp commented Sep 7, 2022

@Pierre-Sassoulas Sure thing! Done! Added testing that checks if the style is applied correctly depending on the toml file.

Regarding the the added lines marked as not being covered (not implemented error) by definition cannot be covered.
It will be raised if the implementation of the arguments changes in a way that is not supported by the parser (without it, it will fail silently instead of raising an error)

@github-actions

This comment has been minimized.

@DanielNoord
Copy link
Owner

Regarding the the added lines marked as not being covered (not implemented error) by definition cannot be covered. It will be raised if the implementation of the arguments changes in a way that is not supported by the parser (without it, it will fail silently instead of raising an error)

You can add a # pragma: no cover comment to this line to force the coverage to pass there.

Could you also take a look at the failing pre-commit run?

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@jspaezp
Copy link
Contributor Author

jspaezp commented Sep 7, 2022

Regarding the the added lines marked as not being covered (not implemented error) by definition cannot be covered. It will be raised if the implementation of the arguments changes in a way that is not supported by the parser (without it, it will fail silently instead of raising an error)

You can add a # pragma: no cover comment to this line to force the coverage to pass there.

Could you also take a look at the failing pre-commit run?

I am not sure why the mypy pre-commit is failing, it fails with error:

pydocstringformatter/_configuration/toml_parsing.py:52: error: Module has no attribute "_ExtendAction"; maybe "_AppendAction"?  [attr-defined]
Found 1 error in 1 file (checked 37 source files)

which is odd ... since it has been added since python 3.8 (and the fact that the code runs, if the object did not exist it would result in a runtime error):

python/cpython@aa32a7e

Copy link
Collaborator

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

LGTM, we need to silence the mypy error if it's passing all the test imo.

pydocstringformatter/_configuration/toml_parsing.py Outdated Show resolved Hide resolved
jspaezp and others added 2 commits September 7, 2022 13:25
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
@github-actions

This comment has been minimized.

@DanielNoord DanielNoord self-requested a review September 7, 2022 17:36
@DanielNoord
Copy link
Owner

LGTM, we need to silence the mypy error if it's passing all the test imo.

Hmm, I don't really agree. It seems as if the pre-commit environment uses python3. That could be an older version.

We should at least try setting the pre-commit.ci environment to use 3.10 and see if that helps.

@Pierre-Sassoulas
Copy link
Collaborator

We should at least try setting the pre-commit.ci environment to use 3.10 and see if that helps.

I think that's the default right now ? Otherwise the option is language_version: python3.10

@jspaezp
Copy link
Contributor Author

jspaezp commented Sep 7, 2022

I have tried several configurations to set the python version and none seems to fix the error.
Even locally installing mypy and passing the arguments ...

$   python -m mypy --config-file=pyproject.toml
pydocstringformatter/_configuration/toml_parsing.py:6: error: Module "argparse" has no attribute "_ExtendAction"; maybe "_AppendAction"?  [attr-defined]
pydocstringformatter/_testutils/primer/packages.py:57: error: Module has no attribute "Repo"  [attr-defined]
Found 2 errors in 2 files (checked 34 source files)

$   python -m mypy --config-file=pyproject.toml --python-version=3.10
pydocstringformatter/_configuration/toml_parsing.py:6: error: Module "argparse" has no attribute "_ExtendAction"; maybe "_AppendAction"?  [attr-defined]
pydocstringformatter/_testutils/primer/packages.py:57: error: Module has no attribute "Repo"  [attr-defined]
Found 2 errors in 2 files (checked 34 source files)

$   python -m mypy --version                                      
mypy 0.971 (compiled: yes)

$  python --version
Python 3.10.4

$   python -c "import argparse ; print(argparse._ExtendAction)"
<class 'argparse._ExtendAction'>

$   python -c "import git ; print(git.Repo)"
<class 'git.repo.base.Repo'>

@DanielNoord
Copy link
Owner

Oh wow, it seems like typeshed hasn't been updated for this.

See https://github.com/python/typeshed/blob/master/stdlib/argparse.pyi.

If you want you can open an issue or PR for this against typeshed. I think they would appreciated that.

I'll try and get a review of this PR tonight. Thanks for the testing you already did @jspaezp!

@jspaezp
Copy link
Contributor Author

jspaezp commented Sep 7, 2022

Wow! I did not know about typeshed!

Just for reference in the future:
PR adding _ExtendAction to typeshed:
python/typeshed#8701

It got approved! so in time mypy will work correctly

@DanielNoord
Copy link
Owner

Wow! I did not know about typeshed!

Just for reference in the future: PR adding _ExtendAction to typeshed: python/typeshed#8701

It got approved! so in time mypy will work correctly

Congratulations on your first contribution! 🎉

@Pierre-Sassoulas
Copy link
Collaborator

It got approved! so in time mypy will work correctly

This is also going to impact pylint 😄

python/typeshed#8701 (comment)

@github-actions

This comment has been minimized.

Copy link
Owner

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

Thank you very much @jspaezp for all the work here.

Sadly this PR unearthed another issue within the tool that (after being addressed) will break the current test. I have given some pointers to making a new test. If you need any help please let me know!

pydocstringformatter/_configuration/toml_parsing.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
@jspaezp jspaezp requested a review from DanielNoord September 9, 2022 00:24
@github-actions

This comment has been minimized.

@jspaezp jspaezp requested a review from DanielNoord September 9, 2022 21:33
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

tests/test_config.py Outdated Show resolved Hide resolved
@github-actions

This comment has been minimized.

tests/test_config.py Outdated Show resolved Hide resolved
@github-actions
Copy link

According to the primer, this change has no effect on the checked open source code. 🤖🎉

@DanielNoord DanielNoord enabled auto-merge (squash) September 10, 2022 08:30
@DanielNoord
Copy link
Owner

Thanks @jspaezp 😄

@DanielNoord DanielNoord merged commit 60a82b3 into DanielNoord:main Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect reading of pyproject.toml
3 participants