Tiny first patch assistance

Hi all,
I’ve just install HA Core onto a spare Raspberry Pi the other day, and have found my first bug when trying to get the Cisco Meraki integration working. I’ve found and fixed the issue in my own source and was trying to work out how to share the fix back to the project.

This is my first attempt to do so on github, as well as my first attempt to modify a python script, so I’m not very familiar with any of the usual formatting guides etc. I thought it was such a small simple fixx, that it should be easy to contribute, and could be quite helpful for those people trying to use it.

So far, I’ve created my own fork on github, then made the change, and committed it as a pull request (I don’t think all that was actually needed, but anyway), I’ve also made a pull request on the main HA project, and have now received a message saying that it has failed some automated tests (the isort test).

From my reading, this appears to be related to the order that the libraries are imported, and there is a specific order/preference for doing this.

Here is the link to my pull request:

The part that is failing is here:

import logging

import voluptuous as vol
from decimal import Decimal

from homeassistant.components.device_tracker import (
    PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,

I’ve added the line “from decimal import Decimal”…
Rather than just make random guesses, I was wondering if someone could provide some guidance on where to put the line, and a brief explanation on why (so that next time I can get it right myself).

Aside from that issue, if anyone could advise on other things I might have done in the above process, I’d also be keen to try to fix them and find better ways to contribute in future.

Regards,
Adam

Don’t get me started on the bazillions formatting checks done by python projects in general, and HA Core in particular :wink:

In your case, “isort” tells you what it expects:

 """Support for the Meraki CMX location service."""
+from decimal import Decimal
 import json
 import logging
 
 import voluptuous as vol
-from decimal import Decimal
 
 from homeassistant.components.device_tracker import (
     PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,

Don’t ask me for the logic behind it, I have no clue…