Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alex-lee
Copy link
Contributor

@alex-lee alex-lee commented May 2, 2020

I wanted to incorporate black-macchiato into a plugin, so I refactored the macchiato function to expose the wrapping functionality. I'm not sure if this is the sort of change you'd want to merge, but in case it looks worthwhile, here it is 🙂


# Read input.
lines = in_fp.readlines()
class WrapInfo(NamedTuple):
Copy link
Owner

Choose a reason for hiding this comment

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

can't say i like namedtuples in general, but i guess using dataclass means this code won't work with python3.6 anymore...

macchiato.py Outdated
if black_args is None:
black_args = []

with tempfile.NamedTemporaryFile(suffix=".py", mode="wt+", delete=False) as fp:
Copy link
Owner

Choose a reason for hiding this comment

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

while at it, maybe write the temp file file in the os.getcwd()? see my comments in #4.

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, I've made the change for this and added some tests to see if the config file is detected properly.

@wbolster
Copy link
Owner

wbolster commented May 7, 2020

hey @alex-lee thanks for your interest. happy to merge this; left a few comments.

this whole project started out as a really quick 'n dirty hack, and hence was just the simplest ‘stupid’ script that could work... but then i added support for new corner cases, and other people added more... 🙈

and while i'm not really comfortable treating this code as a ‘library’ (instead of a command line tool), in practice the changes needed for that are not that big anyway, and this pull request does that in a more than decent way (docstrings, type annotations, various cleanups, and so on). so yeah, :shipit: 👍

alex-lee added 2 commits May 8, 2020 14:15
If there is an existing project config, it will be detected and used.
@alex-lee
Copy link
Contributor Author

alex-lee commented May 8, 2020

Thanks for taking a look @wbolster and for the comments! Let me know if the working directory change and the related tests look ok.

Copy link
Owner

@wbolster wbolster left a comment

Choose a reason for hiding this comment

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

this looks great, thanks!

@wbolster wbolster merged commit a330263 into wbolster:master May 14, 2020
@wbolster
Copy link
Owner

fyi i pushed 1.3.0 with these changes to pypi: https://pypi.org/project/black-macchiato/1.3.0/

@wbolster
Copy link
Owner

heh and looking at that page it reminded me of #3 🙈

@alex-lee alex-lee deleted the refactor-for-plugin-use branch May 16, 2020 13:45
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.

2 participants