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

Max line length #105

Merged
merged 4 commits into from
May 23, 2022
Merged

Max line length #105

merged 4 commits into from
May 23, 2022

Conversation

mdczaplicki
Copy link
Contributor

@mdczaplicki mdczaplicki commented May 23, 2022

Small update to have max-line-length as a argument.

Sorry, but didn't have time to make tests pass. Some magic happens below 😛

Closes #90

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 for taking this on @mdczaplicki. Very much appreciated!

I left some comments, let me know if you have any questions!

.gitignore Outdated Show resolved Hide resolved
docs/usage.rst Outdated
@@ -17,6 +17,7 @@ Current usage of ``pydocstringformatter``:
[--capitalize-first-letter --no-capitalize-first-letter]
[--final-period --no-final-period]
[--quotes-type --no-quotes-type]
[--max-line-length MAX_LINE_LENGTH]
Copy link
Owner

Choose a reason for hiding this comment

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

It seems the CI fails here. You could try:

cd docs
make html

That should update the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did that. Unfortunately pipelines still complain

pydocstringformatter/configuration/arguments_manager.py Outdated Show resolved Hide resolved
pydocstringformatter/formatting/base.py Show resolved Hide resolved
requirements-test.txt Show resolved Hide resolved
@@ -0,0 +1 @@
--max-line-length 50
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure this works. We might need:

Suggested change
--max-line-length 50
--max-line-length=50

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that's why :D

Copy link
Owner

Choose a reason for hiding this comment

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

If I remember correctly it just reads all .args files and splits on every space it encounters. Then it basically calls:
pydocstringformatter --max-line-length 50 test.py. So these files should mimic how you would normally call the program on CLI

@@ -0,0 +1,13 @@
def func():
Copy link
Owner

Choose a reason for hiding this comment

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

Basically the test should have 3 cases:

  1. One multi-line summary clearly above 50 characters. > Summary should be wrapped.
  2. One multi-line summary with a description above 50 chars. > Summary should be wrapped, but description shouldn't as we don't support that.
  3. One single-line docstring that is 49 chars without the final quotes. See LinesChunk.
    If it is a single-line docstring we need to add the final quotes on the same line, so the line is not actually 49 but 52, so we should indeed wrap. That is what LinesChunck is testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Updated them. But for some reason it seems that 50 is not picked up in this test.

Copy link
Owner

Choose a reason for hiding this comment

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

I think this is because the option doesn't use type. You could add a breakpoint somewhere after line_length = self.config.max_line_length but I think line_length will now be "50" instead of 50. This can be fixed by using type=int in the add_argument call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually says that all docstrings are properly formatted. So it doesn't run

@@ -0,0 +1,2 @@
--linewrap-full-docstring
Copy link
Owner

Choose a reason for hiding this comment

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

@mdczaplicki I have pushed some changes. Turns out I was being very dumb.

Since line wrapping is still experimental it is not enabled by default. So for the test to run, it also needs this flag set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem. Thanks for the help here :D

Copy link
Owner

Choose a reason for hiding this comment

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

No worries and thanks very much for doing the initial work. It's much easier as maintainer to build on a PR that's 90% done than starting from scratch.

Sorry for the spam you're getting right now. There is something wrong with one of our test runs but I can only test it on a PR opened by somebody that is not a contributor... I'll clean the commits in this PR up after I have fixed the issue and then merge this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests pass locally. 🎉

BTW. I believe there is a problem with make html. I was running it, but pipelines complained.

Also:

❯ cd docs
❯ pip install -e .
Obtaining file:///home/marek/PycharmProjects/pydocstringformatter/docs
ERROR: file:///home/marek/PycharmProjects/pydocstringformatter/docs does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.
❯ pip install -r requirements-doc.txt
Obtaining file:///home/marek/PycharmProjects/pydocstringformatter/docs (from -r requirements-doc.txt (line 1))
ERROR: file:///home/marek/PycharmProjects/pydocstringformatter/docs (from -r requirements-doc.txt (line 1)) does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

However it works when I go

cd ..

and then

pip install -r docs/requirements-doc.txt

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah it should be:

pip install -e .
cd docs
make html

This is due to how readthedocs install dependencies from root. So we need to install them from root as well...

@coveralls
Copy link

coveralls commented May 23, 2022

Pull Request Test Coverage Report for Build 2371300890

  • 2 of 2 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2371299252: 0.0%
Covered Lines: 471
Relevant Lines: 471

💛 - Coveralls

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.

One final spelling change.

I'm also using this PR to test some changes to the primer. Sorry for the merge commit spam 😅

pydocstringformatter/configuration/arguments_manager.py Outdated Show resolved Hide resolved
docs/usage.rst Outdated Show resolved Hide resolved
@github-actions

This comment has been minimized.

@github-actions
Copy link

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

@DanielNoord DanielNoord merged commit b824fee into DanielNoord:main May 23, 2022
@DanielNoord
Copy link
Owner

Thanks once again @mdczaplicki, also for prompting me to final fix our CI 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to specify max line length
4 participants