On Sun, 2021-03-28 at 15:42 +0000, Travis Griggs wrote: > I've been looking into using a code formatter as a code base size has > grown as well as contributing developers. I've found and played with > autopep, black, and yapf. As well as whatever pycharm has (which may > just be gui preferences around one of those 3). > > I have 2 questions: > 1) Are there any major other formatters that I can/should look at? I > see some "online" pretty printers, but I'm after something I can run > on whole recursive directories of code.
I assume you mean autopep8. I'm not aware of any other currently popular formatters. > 2) I use more and type annotations (at least at the trivial level). > But I like to have variable annotations tightly bound to the > identifier, kind of like a subscript. So I want to see > > def foo_bar(baz:int) -> bool: > yak:str = 'howdy mates' > > And NOT > > def foo_bar(baz: int) -> bool: > yak: str = 'howdy mates' > > In other cases though (dictionaries for example), I'm fine with (and > prefer) the spacing. > > Is there anyway to make any of these formatters do this? Formatters are typically strongly opinionated (autopep8 being an exception), so I think you'll be going against the grain by trying to make exceptions. I suggest accepting their opinions (pick the formatter that most closely aligns with your taste), or, if you can make a case for general use, suggest/request one change their opinions. Paul -- https://mail.python.org/mailman/listinfo/python-list