Skip to content

Conversation

Pierre-Sassoulas
Copy link
Collaborator

This is a proposition so it's easier to add Formatter later on and remove some duplicated calls. (Based on #8)

@Pierre-Sassoulas Pierre-Sassoulas added the enhancement New feature or request label Jan 3, 2022
@Pierre-Sassoulas Pierre-Sassoulas force-pushed the capitalize-first-letter branch 2 times, most recently from 3320b7b to 28db19b Compare January 3, 2022 10:53
@DanielNoord
Copy link
Owner

I like this approach!

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the capitalize-first-letter branch from 28db19b to a3ac539 Compare January 3, 2022 12:57
@Pierre-Sassoulas Pierre-Sassoulas changed the base branch from capitalize-first-letter to main January 3, 2022 13:01
@Pierre-Sassoulas Pierre-Sassoulas changed the title Refator of the formatter to scale better later on Refactor of the formatter to scale better later on Jan 3, 2022
return new_string


class ClosingQuotesFormatter(Formatter):
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't this be a StringFormatter as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

return self._format_multiline_ending_quotes(tokeninfo) returns a token

Copy link
Owner

Choose a reason for hiding this comment

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

It does, but only ever changes the string. It's a bad design that gets shown by this wonderful refactor! 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm but it needs the token and not the string to work. Maybe treat_string needs to take a token as input ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or we could initialize the formatters for each loop and the token become a class attribute.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah that makes sense I think.

Copy link
Owner

Choose a reason for hiding this comment

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

Or we could initialize the formatters for each loop and the token become a class attribute.

That sounds like a large impact on performance. Would probably still be manageable, but I like how quick the tool runs at the moment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've refactored treat_string, the result does look cleaner.

@DanielNoord
Copy link
Owner

@Pierre-Sassoulas Just something I found while reading the PEPs (and to be added at a later point) one-liner's and summary lines should be sentences ending with a point. I have not done that myself for some of the docstrings I already wrote, but we might as well start doing this ourselves now.

@Pierre-Sassoulas
Copy link
Collaborator Author

I can remove the setup.py commit so we merge this one first if this is controversial 😉 .

@DanielNoord
Copy link
Owner

I can remove the setup.py commit so we merge this one first if this is controversial 😉 .

Would be good I think! I hate having to scroll down two pages on a Github repository because of all the config files, that's why I'd like to enforce not having a setup.py.

I should add a build-system section though, so that's on the TODO-list.

@DanielNoord DanielNoord added this to the 0.3.0 milestone Jan 3, 2022
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.

Three final comments! I think this can be squashed and merged 😄

Congratulations on becoming a pydocstringformatter contributor 😉

Pierre-Sassoulas and others added 2 commits January 3, 2022 14:36
Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
@Pierre-Sassoulas Pierre-Sassoulas merged commit b89147c into main Jan 3, 2022
@Pierre-Sassoulas Pierre-Sassoulas deleted the formatter-refactor branch January 3, 2022 13:39
@Pierre-Sassoulas
Copy link
Collaborator Author

Congratulations on becoming a pydocstringformatter contributor

It's actually nice to be on a project with a bug to feature ratio of 0%, how do you do that ? 😄

@DanielNoord
Copy link
Owner

Congratulations on becoming a pydocstringformatter contributor

It's actually nice to be on a project with a bug to feature ratio of 0%, how do you do that ? 😄

Rigorous reviews of all PRs 😄

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.

2 participants