-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Update docstrings #7374
Update docstrings #7374
Conversation
@fabaff, thanks for your PR! By analyzing the history of the files in this pull request, we identified @MartinHjelmare, @rytilahti and @olimpiurob to be potential reviewers. |
return self._media_album_artist | ||
|
||
@property | ||
def media_track(self): | ||
"""Track number of current playing media, music track only.""" | ||
"""Return the track number of current playing media, music track only.""" |
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.
line too long (81 > 79 characters)
else: | ||
_LOGGER.info('%s is disconnected. Attempting to reconnect.', | ||
_LOGGER.info(""%s is disconnected. Attempting to reconnect"", |
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.
missing whitespace around modulo operator
SyntaxError: invalid syntax
@@ -85,20 +85,20 @@ def device_update_callback(data): | |||
new_devices.append(new) | |||
|
|||
elif dev_id in inactive_emby_devices: | |||
if emby.devices[dev_id].state != 'Off': | |||
if Callbackemby.devices[dev_id].state != 'Off': |
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.
undefined name 'Callbackemby'
return self._media_album_artist | ||
|
||
@property | ||
def media_track(self): | ||
"""Track number of current playing media, music track only.""" | ||
"""Return the track number of current playing media, music track only.""" |
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.
line too long (81 > 79 characters)
else: | ||
_LOGGER.info('%s is disconnected. Attempting to reconnect.', | ||
_LOGGER.info(""%s is disconnected. Attempting to reconnect"", |
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.
missing whitespace around modulo operator
SyntaxError: invalid syntax
@@ -85,20 +85,20 @@ def device_update_callback(data): | |||
new_devices.append(new) | |||
|
|||
elif dev_id in inactive_emby_devices: | |||
if emby.devices[dev_id].state != 'Off': | |||
if Callbackemby.devices[dev_id].state != 'Off': |
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.
undefined name 'Callbackemby'
I'd like us to decide if we should have double quotes on all log strings or not. It's not part of PEP8 as far as I know but if home assistant makes it its standard we can all follow that. Either we make it standard or we should stop changing it. I've been following whole module consistency, but not whole project consistency. I don't care what we decide, but we need to have a standard to follow. |
@@ -1,4 +1,4 @@ | |||
""" | |||
""" |
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.
IndentationError: unexpected indent
indentation is not a multiple of four
unexpected indentation
SENSOR_TYPES[octo_type][1], | ||
tool) | ||
new_sensor = OctoPrintSensor( | ||
octoprint.OCTOPRINT, temp_type,temp_type, name, |
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.
missing whitespace after ','
ILLUMINANCE, SPEED_MS, CONF_MINIMUM, | ||
CONF_MAXIMUM) | ||
from homeassistant.const import ( | ||
TEMP_CELSIUS, TEMPERATURE, CONF_TYPE,ILLUMINANCE, SPEED_MS, CONF_MINIMUM, |
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.
missing whitespace after ','
CONF_TYPE) | ||
from homeassistant.const import ( | ||
CONF_FRIENDLY_NAME, CONF_SWITCHES, CONF_COMMAND_OFF, CONF_COMMAND_ON, | ||
ONF_TIMEOUT, CONF_HOST, CONF_MAC,CONF_TYPE) |
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.
missing whitespace after ','
CONF_COMMAND_OFF, CONF_COMMAND_ON, | ||
CONF_TIMEOUT, CONF_HOST, CONF_MAC, | ||
CONF_TYPE) | ||
from homeassistant.const import ( |
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.
'homeassistant.const.ONF_TIMEOUT' imported but unused
"Outdoor motion": 'motion', | ||
"Outdoor human": 'motion', | ||
"Outdoor animal": 'motion', | ||
"Outdoor vehicle": 'motion' |
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.
Converting only the value part doesn't make much sense, does it?
name = "yeelight_%s_%s" % (discovery_info["device_type"], | ||
discovery_info["properties"]["mac"]) | ||
name = 'yeelight_{}_{}'.format( | ||
discovery_info['device_type'], discovery_info['properties']['mac']) |
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.
Imo format string changes should be discussed separately. In the future (with 3.6) it'd be nice to use f-strings directly, however for now I don't see what good does this change do (when not naming the placeholders, that is)?
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.
If we suggest to use string formatting in PR then we should be consistent.
@@ -85,7 +84,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): | |||
device = {'name': device_config[CONF_NAME], 'ipaddr': ipaddr} | |||
lights.append(YeelightLight(device, device_config)) | |||
|
|||
add_devices(lights, True) # true to request an update before adding. | |||
add_devices(lights, 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.
This is there to remind that add_devices() has a magic boolean flag. It may also be useful for developers looking how others have done adding. In any case I think this kind of cleanups would deserve their own PR & discussion.
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.
That's covered in the docs. No need to have that on a single place in the code.
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.
Very implicitly, but can be fixed with a documentation update. Maybe enforcing using kwarg for booleans as a general policy? Would turn it to add_devices(lights, update_before_adding=True) to make it clear?
@@ -204,7 +204,7 @@ def media_track(self): | |||
|
|||
@property | |||
def media_series_title(self): | |||
"""The title of the series of current playing media (TV Show only).""" | |||
"""Return te title of the series of current playing media (TV only).""" |
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.
Typo
@@ -101,15 +101,15 @@ def _setup_sources(self, telnet): | |||
@classmethod | |||
def telnet_request(cls, telnet, command, all_lines=False): | |||
"""Execute `command` and return the response.""" | |||
_LOGGER.debug('Sending: "%s"', command) | |||
_LOGGER.debug("Sending: %s", command) |
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.
Here changing from '' to "" instead of other way around? It'd however be nice to keep the outputted command quoted as it was.
track_time_change( | ||
hass, self.update, second=config.get(CONF_SECOND), | ||
minute=config.get(CONF_MINUTE), hour=config.get(CONF_HOUR), | ||
day=config.get(CONF_DAY)) |
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.
The existing one looks to me much more readable with one line per kwarg.
I would prefer if we keep cleanups to the minimum necessary to get the upgrade of pydocstyle or pylint going. By updating other code, we can a) introduce bugs and b) mask author of code in git blame |
Me too but as I needed to edit almost every file it was only efficient to update the most obvious and minor things we want have changed in PRs like string formatting and the removal of blank lines or update of comments was a side effect. The format of the log messages is a different topic and for another day. It wouldn't harm to have a more uniform style as we know for sure that people are feeding the log to their tools. |
Ok, I collected the things which always lead to discussions and create a page with details about the style. |
As I don't know where this would be best discussed, just adding my last comment regarding to the quote styling. Having two types of quotes makes it very hard to keep it consistent on the long run if the content of those variables may live (e.g. are not just constants). If this is to be enforced it would be nice to describe in the style guide why it makes sense to do so. P.S. about the quotations in log messages, using them makes it (in my opinion) easier, not harder to parse for both people and with regular expressions. A fully structured logging format would be the best but it may be hard to pull consistently. P.P.S. In the file header example, "For more details about this platform, please refer to the documentation at" crosses the line length limit of 72 for docstrings as defined in PEP8. Just my 0.02e :-) |
Good with the page. In my opinion mixing single and double quotes and having different style depending on the length of the string, makes for a harder to follow style. I'd prefer it to be clear and simple. Eg either use single quotes in whole module or double quotes in whole module. |
I agree with @fabaff , thanks for adding the page 👍 |
Description:
Preparation for #7357.
Checklist:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests pass