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

Remove docformatter as a pre-commit hook #1074

Merged
merged 4 commits into from
Jan 31, 2023

Conversation

rmartin16
Copy link
Member

@rmartin16 rmartin16 commented Jan 30, 2023

Small fixes to make these formatters happy(er)...

Relevant issue: PyCQA/docformatter#154

Removed docformatter as a pre-commit hook. By and large, black serves the purpose of formatting docstrings.

Because removing docformatter, I ran it one last time using black's default docstring width of 88 characters.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

So - these changes all look fine... at the very least, the missing tests are a big review OOPS on my part - but I'm not sure I'm following what the actual problem is here. You seem to be suggesting there's a code-style issue... but I haven't seen any problems reported by pre-commit, and there's no pre-commit configuration change associated with this PR that might induce one.

Can you elaborate on how you're observing the problem that this PR fixes?

"text": True,
"encoding": CONSOLE_ENCODING,
"cwd": cwd_override,
}
Copy link
Member

Choose a reason for hiding this comment

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

I was clearly having a good day when I approved this tests the first time around...

@rmartin16
Copy link
Member Author

These are problematic in versions of linters we aren't currently using. The next release of docformatter, v1.6.0, is currently not handling "empty" functions very well. It is documented in PyCQA/docformatter#154.

@rmartin16
Copy link
Member Author

As an example, here's what docformatter==1.6.0-rc2 was doing to linuxdeploy.py:

❯ docformatter src/briefcase/integrations/linuxdeploy.py 
--- before/src/briefcase/integrations/linuxdeploy.py
+++ after/src/briefcase/integrations/linuxdeploy.py
@@ -35,12 +35,10 @@
     @abstractmethod
     def download_url(self):
         """The URL where the tool/plugin can be downloaded."""
-
     @property
     @abstractmethod
     def file_path(self):
         """The folder on the local filesystem that contains the file_name."""
-
     def exists(self):
         return (self.file_path / self.file_name).exists()

Also, I wouldn't care so much about these RC releases except pre-commit autoupdate will use them to update .pre-commit-config.yaml.

@freakboy3742
Copy link
Member

Ok - that makes sense. However, I wonder if the fix is to remove the docformatter pre-commit.

We haven't enabled it on Toga and Rubicon because it chokes hard on formatting of ReST references (PyCQA/docformatter#124). At the end of the day, I don't know I've seen docformatter pick up any problems that I'd actually consider bugs, outside of line length issues that are already picked up by black - but it definitely likes reformatting docstrings in a way that hits the pre-commit check on almost every test I've ever written.

The 2 missing tests definitely need to be preserved, though :-)

@rmartin16
Copy link
Member Author

The primary role that docformatter seems to be serving for Briefcase is limiting the first line of a docstring to 79 characters and subsequent lines to 72 characters. Alternatively, black seems to limit both of these to 88 characters.

@freakboy3742, before I get rid of docformatter, do you think it would be worth me running it with a 88 character limit to align all the docstrings better with black?

@freakboy3742
Copy link
Member

I'm happy to live with an 88 character limit; if it's easy to reprocess the docstrings to get them out to an 88 char limit, then sure, but if it's more than a couple of minutes work, I don't think it matters that much if existing lines stay 9-16 chars short.

@rmartin16
Copy link
Member Author

It's simple; just add --wrap-descriptions=88, --wrap-summaries=88 to the args for docformatter in .pre-commit-config.yaml.

@rmartin16 rmartin16 changed the title Ensure every function has body content Remove docformatter as a pre-commit hook Jan 31, 2023
Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

A bit of a monster diff, but definitely worth it. The number of "barely over 79/72 char" lines that are cleaned up speaks for itself, IMHO.

@freakboy3742 freakboy3742 merged commit 843e3f4 into beeware:main Jan 31, 2023
@rmartin16 rmartin16 deleted the misc-fixes branch January 31, 2023 05:59
@rmartin16
Copy link
Member Author

FYI; I realized today that docformatter was also the one responsible for ensuring the first line of all of our docstrings end in a period. Not huge....but I'll probably miss that a little bit.

@freakboy3742
Copy link
Member

Agreed it's annoying, but not the end of the world. We'll just have to remember how to punctuate

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

Successfully merging this pull request may close these issues.

None yet

2 participants