-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add formatters #24
Add formatters #24
Conversation
|
||
Parameters | ||
---------- | ||
statement : ImportStatement instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpik - this is numpy doc - on first line you have var name and its type. on next then you add description. so instance
is not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I just remove the word instance?
- Added a formatter file to store formatter classes - Ignore flake8 E731,W503 due to recent update of pep8 - Added a new VerticalHangingFormatter - Added a separate file to test formatters - Add config & argument and check existence of formatter - Fix tests for new formatter config/arg - Updated README to explain usage of formatters - Added pypy3 interpreter to tests
Changes Unknown when pulling e2188f6 on benjaminabel:formatters into * on miki725:formatters*. |
string += '{})'.format(self.file_artifacts.get('sep', '\n')) | ||
|
||
return string | ||
def formatted(self, formatter='IndentWithTabsFormatter'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather pass here actual class so no import is necessary. Since formatters could be pretty generic, we might want to allow people to use custom formatters even if they are not in core importanize...
@miki725 When browsing django code, I've seen that Django already use a tool to sort imports see this commit. It's |
@benjaminabel haha. good questions. I needed a utility for sorting imports at work which is why I started importanize. When I was done, only then I found out about |
I tried to implement your changes however I can't figure out how to pass the formatter class catched from the main.py file to the ImportStatement class in statements file. @minrk thanks for your help and your reviews. I don't think I can go further on the issue. Do you want that I close it or you may want to finish it yourself? |
No problem. I can finish this. Thanks for contributing! |
This is done. Thanks for your help @miki725 |
ok. great. thanks @benjaminabel for your contribution. Ill leave the PR open until Ill have a chance to finish this up in case you will want to push more changes. |
I don't think I got the technical capabilities to finish this. I need to learn more! |
I think all of us need to learn more! |
This is a continuation of #23 which tries to fix the issue #12 .
Currently two formatters classes are available, the default one
IndentWithTabsFormatter
and a newVerticalHangingFormatter
.All tests pass, however I don't know anything about mock, and I don't know if I did it right, and I can't figure out how to add tests for new config and argument
formatter
.Here's the TODO from #23 :
--formatter
option in the scriptformatted()
tests totest_formatters.py
README
I think everything is OK,