kamaradclimber / vigieau

A custom integration for home-assistant on the Vigieau dataset
Apache License 2.0
18 stars 4 forks source link

Clean code #81

Closed chpego closed 6 days ago

chpego commented 1 week ago

Un peu de nettoyage de code avec quelques bonnes pratiques et puis quelques corrections de mots

Je n'ai pas testé si le code fonctionne correctement, je manque d'expérience pour tester mes modifs en local

kamaradclimber commented 6 days ago

Hello,

merci pour la contribution.

Le plus simple pour tester le code en local est d'utiliser docker ou podman. Par exemple, depuis la raçine du repo: podman run -ti --network=host -v $(pwd):/config ghcr.io/home-assistant/home-assistant:2024.10.

En lanchant la commande, j'obtiens:

2024-11-19 19:39:50.501 ERROR (ImportExecutor_0) [homeassistant.loader] Unexpected exception importing component custom_components.vigieau
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1067, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/vigieau/__init__.py", line 32, in <module>
    from .api import VigieauAPI, VigieauAPIError
  File "/config/custom_components/vigieau/api.py", line 7, in <module>
    from .const import ADDRESS_API_URL, GEOAPI_GOUV_URL, VIGIEAU_API_URL
  File "/config/custom_components/vigieau/const.py", line 21, in <module>
    ZIP_CODE: "Code Postal",
    ^^^^^^^^
NameError: name 'ZIP_CODE' is not defined