def _sync_class_booking(raw_class: Dict,
fitness_person: FitnessPerson,
booking_provider: BookingProvider,
payment_provider: PaymentProvider):
went to this:
def _sync_class_booking(raw_class: Dict, fitness_person: FitnessPerson, booking_provider: BookingProvider,
payment_provider: PaymentProvider):
when running yapf -i --style='{based_on_style: pep8, column_limit: 120}'. It's desirable to leave this unchanged. The rule would be, in plain English, "put function arguments on their own lines if they won't all fit on one line". I've attempted to get this working with the current settings but did not find a solution.
yapf verison: 0.7.0
Not sure if this is related but got two different functions reformats results in the same yapf ran.
def editMessageCaption(self,
chat_id=None,
message_id=None,
inline_message_id=None,
caption=None,
**kwargs):
...
def sendVenue(
self, chat_id,
latitude,
longitude,
title, address,
foursquare_id=None,
**kwargs):
Not sure why YAPF is breaking lines after ( for this case and not aligning arguments. Probably because I'm not defining default values for args in sendVenue?
Version: 0.8.0
Found on: python-telegram-bot/python-telegram-bot#259
@lexicalunit If you add a comma at the end of the list, then it remains the same. Otherwise, I don't know if we can do much here.
$ python -m yapf --style='{base_on_style: pep8, column_limit: 120}' < /tmp/x.py
def _sync_class_booking(raw_class: Dict,
fitness_person: FitnessPerson,
booking_provider: BookingProvider,
payment_provider: PaymentProvider,):
pass
@leandrotoledo Weird. I get this:
$ python -m yapf < /tmp/y.py
def editMessageCaption(self,
chat_id=None,
message_id=None,
inline_message_id=None,
caption=None,
**kwargs):
pass
def sendVenue(self,
chat_id,
latitude,
longitude,
title,
address,
foursquare_id=None,
**kwargs):
pass
@gwelymernans seems like it is something with --style {column_limit:99}, on 79 chars I'm getting the same as you.
Thanks!
With column_limit set to 99, I get the following:
$ python -m yapf --style='{based_on_style: pep8; column_limit: 99}' /tmp/x.py
def editMessageCaption(self,
chat_id=None,
message_id=None,
inline_message_id=None,
caption=None,
**kwargs):
pass
def sendVenue(self, chat_id, latitude, longitude, title, address, foursquare_id=None, **kwargs):
pass
What's happening is that yapf will place all of the parameters on the same line if they fit (sendVenue). But if they don't fit, then if some parameters have default values, then the elements will be on separate lines (editMessageCaption). It's kind of a silly heuristic, but one that many people asked for...
@gwelymernans I can finally reproduce now, the problem is because it was inside a class, adding to it 4 space indention block prior def, note that for sendVenue args - beside the fact they are not aligned to (, some lines have two args, like self, chat_id, and title, address,. Is this WAI? Thanks!
$ python -m yapf --style='{based_on_style: google; column_limit: 99}' /tmp/x.py
class Bot(object):
def editMessageCaption(self,
chat_id=None,
message_id=None,
inline_message_id=None,
caption=None,
**kwargs):
pass
def sendVenue(
self, chat_id,
latitude,
longitude,
title, address,
foursquare_id=None,
**kwargs):
pass
It's definitely not WAI. :-) Here's what I'm getting with top-of-tree:
python -m yapf --style='{based_on_style: google; column_limit: 99}' /tmp/y.py
class Bot(object):
def editMessageCaption(self,
chat_id=None,
message_id=None,
inline_message_id=None,
caption=None,
**kwargs):
pass
def sendVenue(self,
chat_id,
latitude,
longitude,
title,
address,
foursquare_id=None,
**kwargs):
pass
It might have been fixed already?
diff --git a/telegram/bot.py b/telegram/bot.py
index 3147f2e..ae9a8ad 100644
--- a/telegram/bot.py
+++ b/telegram/bot.py
@@ -606,13 +606,14 @@ class Bot(TelegramObject):
@log
@message
- def sendVenue(
- self, chat_id,
- latitude,
- longitude,
- title, address,
- foursquare_id=None,
- **kwargs):
+ def sendVenue(self,
+ chat_id,
+ latitude,
+ longitude,
+ title,
+ address,
+ foursquare_id=None,
+ **kwargs):
Awesome! Thank you very much @gwelymernans!
Excellent! :-)
Most helpful comment
Awesome! Thank you very much @gwelymernans!