-
Notifications
You must be signed in to change notification settings - Fork 1
Appease flake8 #27
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
Appease flake8 #27
Conversation
|
Note: I did not touch ocrd/resource_manager.py because I did not want to create too many clashes with OCR-D#1319. Also, I did only cosmetic changes – but nothing to address |
MehmedGIT
left a comment
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 agree with the changes, and I don't have much to add other than suggesting some improvements that should still be accepted by flake8.
| @click.option('-n', '--name', envvar='OCRD_TOOL_NAME', default='log_cli', metavar='LOGGER_NAME', | ||
| help='Name of the logger', show_default=True) |
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.
| @click.option('-n', '--name', envvar='OCRD_TOOL_NAME', default='log_cli', metavar='LOGGER_NAME', | |
| help='Name of the logger', show_default=True) | |
| @click.option( | |
| '-n', '--name', envvar='OCRD_TOOL_NAME', default='log_cli', metavar='LOGGER_NAME', help='Name of the logger', show_default=True) |
How about that convention on all click options? That should still be acceptable from the POV of the linter. For click commands with more parameters, there will be less leading whitespace on each line. Same for all occurrences.
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.
Shouldn't the follow-up line still be indented 4 spaces, though?
IMO these 13 characters are not much of a saving to warrant this pattern in general – most of our lines will be much longer, anyway. I would still favour breaking only when needed, and aligning indentation to the opening parentheses.
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.
Shouldn't the follow-up line still be indented 4 spaces, though?
Yes.
| def _poll_endpoint_status(ps_server_host: str, job_id: str, job_type: str, tries: int, wait: int, | ||
| print_state: bool = False) -> JobState: |
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.
For the ocrd_network module, generally, I tried to respect the following structures.
def method(
parameter A, parameter B, parameter C, ... ,
parameter X, ...
) -> return_typeor for cases where each parameter may be long when it contains typing, and a default value.
def method(
parameter A,
parameter B: int = DefaultGenerator.getDefault(),
...
) -> return_typeAgain, for the sake of avoiding many leading whitespaces when the method name is somewhat longer. E.g.,
def very_very_very_very_very_very_very_very_long(parameter A, parameter B, parameter C, ... ,
parameter X, parameter Y, ... ) -> return typeAlso more convenient when reviewing code from the web interface of GitHub. If you find that reasonable as well, we may adopt that for the entire repository.
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.
Agreed – for methods and functions, with type annotations taking up so much space nowadays, I am in favour of using your style throughout. (My changes just attempted to get rid of the errors/warnings ad hoc.)
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.
def method( parameter A, parameter B, parameter C, ... , parameter X, ... ) ->
Flake8 mocks this BTW:
E125 continuation line with same indent as next logical line
I guess it must be 8 spaces after the parentheses of the definition.
d11346a
into
ocrd-network-ps-fix-compact-page-range
builds on OCR-D#1334