Stefano Borini <stefano.borini-Re5JQEeQqe8Avxtiu Mwx3w@public.gmane.org> Wrote in message:r
This may be a pet peeve of mine, but with the introduction of typehints, more and more function definitions have become longer than 80characters. This used to seldom happen in the past.The problem, as I see it, is that there seem to be a general tendencyto use this way of indenting, e.g. see (among many):https://github.com/samuelcolvin/pydantic/blob/c71326d4a6898612597d3c647a4256... load_file( path: Union[str, Path], *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False,) -> Any: path = Path(path) b = path.read_bytes() if content_type is None: if path.suffix in ('.js', '.json'): proto = Protocol.json elif path.suffix == '.pkl': proto = Protocol.pickleThis violates pep8# Add 4 spaces (an extra level of indentation) to distinguisharguments from the rest.def long_function_name( var_one, var_two, var_three, var_four): print(va r_one)However, no coding styles tools report that. Flake8 does howeverreport a similar error for if conditions if path.suffix in ( '.js', '.json' ): proto = Protocol.jsonx.py:20:5: E125 continuation line with same indent as next logical lineBut says nothing for this monstrosity, which is the equivalent of theopening case if path.suffix in ( '.js', '.json' ): proto = Protocol.jsonIt is not my intention to trigger a massive discussion. My stance isthat the appropriate visual aspect of the above code should bedef load_file( path: Union[str, Path], *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Any: path = Path(path) b = path.read_bytes()to keep a visual distinction in indentation between the argument listand the function body, as in the spirit of pep8.Regardless of the choice, I think that pep8 should be updated with theappropriate style for this specific case, and style tools shouldenforce this choice.-- Kind regards,Stefano Borini_______________________________________________Python-ideas mailing list -- python-ideas@python.orgTo unsubscribe send an email to python-ideas-leave-+ZN9ApsXKcEdnm+yROfE0A@public.gmane.orghttps://mail.python.org/mailman3/lists/python-ideas.python.org/Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/XKEWGJ... of Conduct: http://python.org/psf/codeofconduct/
PEP 8 is the stdlib style guide, and the type annotations are not used in the stdib. --