[Samuel Colvin] > > I don't see how anyone can say that would be more readable with a 80 > character line limit.
For starters, type annotations don't add anything that good documentation would have required before. In most docstring style guides that I know of, the arguments list is supposed to be at least one line per argument, so really it should look like so: def resolve_annotations(raw_annotations, module_name): """ description of what the function does Arguments: raw_annotations (type annotation): description of raw_annotations module_name (type annotation): description of module name Returns (type annotation): description or return value """ Which can easily be replaced with: def resolve_annotations( raw_annotations: Dict[str, Type[Any]], module_name: Optional[str]) -> Dict[str, Type[Any]]: """ description of what the module does Arguments: raw_annotations: description of raw_annotations module_name: description of module name Returns: description or return value """ Often, I find, people make add a lot of redundant noise to names which is either clear from context like; math.log, not math.mathematical_log_function, or doesn't add anything like; user_data instead of user, or job_info instead of job, or raw_annotations instead of annotations. It's often just as good to write: def resolve(annotations: Dict[str, Type[Any]], module: Optional[str]) -> Dict[str, Type[Any]]: """...""" On Tue, Feb 19, 2019 at 8:30 AM Samuel Colvin <s...@muelcolvin.com> wrote: > I too would argue that it's time to reconsider line length limits. > > But the reason is not monitor changes, or any particularly strong personal > opinion, but changes to python: > > Let's take a real life example from here > <https://github.com/samuelcolvin/pydantic/blob/master/pydantic/utils.py#L246> > (changed > very slightly for this example), in tranitional python the signature might > be: > > def resolve_annotations(raw_annotations, module_name): > > 55 characters, all fine. Now let's look at that same function in modern > python with type hints: > > def resolve_annotations(*, raw_annotations: Dict[str, Type[Any]], > module_name: Optional[str]) -> Dict[str, Type[Any]]: > > 119 characters! No daft 5-word variable names, just a clean (if strict) > function definition. I don't see how anyone can say that would be more > readable with a 80 character line limit. And that's not even an extreme > case, we don't have lots of "Optional[..]" or "Tuple[ThingA, ThingB, > ThingC]". > > Type hints (for good or bad depending on your view point) have made python > code more verbose, that's just a fact. Code that used to fit on one line > with 80char limit now require 120 (or more), therefore in my opinion the > recommendation should change to keep up with changes in python. > > My preference is 120 characters (that's also the default in pycharm I > believe). It works well on a desktop monitor, leaving room for a file > browser and part of another window, it's also fine on a 13" laptop screen. > > Then again, every IDE and linter I've used (even black) allows the line > length to be varried, so this is only really a problem in the standard > library and libraries which adhere closely to pep8. > > Samuel > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/