Skip to content
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

Add codespell support (config, workflow to detect/not fix) and make it fix few typos #2161

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within pyproject.toml
---
name: Codespell

on:
push:
branches: [dev]
pull_request:
branches: [dev]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ repos:
# hooks:
# - id: black
# language_version: python3
- repo: https://github.com/codespell-project/codespell
# Configuration for codespell is in pyproject.toml
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
8 changes: 4 additions & 4 deletions appdaemon/adapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ def register_service(self, service: str, cb: Callable, **kwargs: Optional[Any])
This will automatically make it available to other apps using the `call_service()` API call, as well as publish
it as a service in the REST API and make it available to the `call_service` command in the event stream.
It should be noted that registering services within a plugin's namespace is a bad idea. It could work, but not always reliable
It is recommended to make use of this api, within a user definded namespace, or one not tied to a plugin.
It is recommended to make use of this api, within a user defined namespace, or one not tied to a plugin.

Args:
service: Name of the service, in the format `domain/service`. If the domain does not exist it will be created
Expand Down Expand Up @@ -1754,7 +1754,7 @@ async def call_service(self, service: str, **kwargs: Optional[Any]) -> Any:
return_result(str, option): If `return_result` is provided and set to `True` AD will attempt
to wait for the result, and return it after execution. In the case of Home Assistant calls that do not
return values this may seem pointless, but it does force the call to be synchronous with respect to Home Assistant
whcih can in turn highlight slow performing services if they timeout or trigger thread warnings.
which can in turn highlight slow performing services if they timeout or trigger thread warnings.
callback: The non-async callback to be executed when complete.
hass_result (False, Home Assistant Specific): Mark the service call to Home Assistant as returnng a
value. If set to ``True``, the call to Home Assistant will specifically request a return result.
Expand All @@ -1765,7 +1765,7 @@ async def call_service(self, service: str, **kwargs: Optional[Any]) -> Any:
hass_timeout (Home Assistant Specific): time in seconds to wait for Home Assistant's response for this specific service call. If not specified
defaults to the value of the ``q_timeout`` parameter in the HASS plugin configuration, which itself defaults to 30 seconds. See `Some Notes on Service Calls <APPGUIDE.html#some-notes-on-service-calls>`__
suppress_log_messages (Home Assistant Specific, False): if set to ``True`` Appdaemon will suppress logging of warnings for service calls to Home Assistant, specifically timeouts and non OK statuses. Use this flag and set it to ``True``
to supress these log messages if you are performing your own error checking as described `here <APPGUIDE.html#some-notes-on-service-calls>`__
to suppress these log messages if you are performing your own error checking as described `here <APPGUIDE.html#some-notes-on-service-calls>`__



Expand Down Expand Up @@ -2406,7 +2406,7 @@ async def reset_timer(self, handle: str) -> bool:

Args:
handle: A valid handle value returned from the original call to create the timer.
The timer must be actively running, and not a Sun related one like sunrise/sunset for it to be resetted.
The timer must be actively running, and not a Sun related one like sunrise/sunset for it to be reset.

Returns:
Boolean, true if the reset succeeded.
Expand Down
6 changes: 3 additions & 3 deletions appdaemon/app_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ async def check_app_updates(self, plugin: str = None, mode: UpdateMode = UpdateM
- Marks the apps for reloading or removal as necessary
- Restarts the plugin, if specified
- Terminates apps as necessary
- Loads or reloads modules/pacakges as necessary
- Loads or reloads modules/packages as necessary
- Loads apps from the modules/packages
"""
async with self.check_updates_lock:
Expand Down Expand Up @@ -1111,7 +1111,7 @@ async def _init_update_mode(self):
module_file: dir.stem for dir in top_packages_dirs for module_file in dir.rglob("*.py")
}

# Add any aditional import paths
# Add any additional import paths
for path in self.AD.import_paths:
if os.path.isdir(path):
self.add_to_import_path(path)
Expand Down Expand Up @@ -1282,7 +1282,7 @@ async def _terminate_apps(self, mode: UpdateMode, apps: AppActions, modules: Lis
if apps is not None and apps.term:
prio_apps = self.get_app_deps_and_prios(apps.term, mode)

# Mark dependant global modules for reload
# Mark dependent global modules for reload
for app_name in sorted(prio_apps, key=prio_apps.get):
app_path = self.get_path_from_app(app_name)

Expand Down
2 changes: 1 addition & 1 deletion appdaemon/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ async def wait_state(
) -> None:
"""Used to wait for the state of an entity's attribute

This API call is only functional within an async function. It should be noted that when instanciated,
This API call is only functional within an async function. It should be noted that when instantiated,
the api checks immediately if its already on the required state, and if it is, it will continue.

Args:
Expand Down
4 changes: 2 additions & 2 deletions appdaemon/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ async def start_server(self):
await site.start()
except gaierror:
self.logger.error("Invalid host specified in URL for HTTP component")
self.logger.error("As of AppDaemon 4.5 the host name specificed in the URL must resolve to a known host")
self.logger.error("As of AppDaemon 4.5 the host name specified in the URL must resolve to a known host")
self.logger.error("You can restore previous behavior by using `0.0.0.0` as the host portion of the URL")
self.logger.error("For instance: `http://0.0.0.0:5050`")
raise StartupAbortedException("Invalid host specified in URL for HTTP component")
Expand Down Expand Up @@ -899,7 +899,7 @@ async def call_app_endpoint(self, request):
return self.get_response(request, code, "App Not Found")

elif code == 500:
return self.get_response(request, code, "An Error occured while processing request")
return self.get_response(request, code, "An Error occurred while processing request")

response = "OK"
self.access.info("API Call to %s: status: %s %s", endpoint, code, response)
Expand Down
2 changes: 1 addition & 1 deletion appdaemon/plugin_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async def notify_plugin_started(self, name, ns, meta, state, first_time=False):
if not self.stopping:
self.plugin_meta[namespace] = meta

if namespaces != []: # there are multiple namesapces
if namespaces != []: # there are multiple namespaces
for namesp in namespaces:
if state[namesp] is not None:
await utils.run_in_executor(
Expand Down
6 changes: 3 additions & 3 deletions appdaemon/plugins/hass/hassplugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Interface with Home Assistant, send and recieve evets, state etc.
Interface with Home Assistant, send and receive evets, state etc.
"""

import asyncio
Expand Down Expand Up @@ -102,7 +102,7 @@ def init_q(self):
self.queues = {}

async def process_response(self, response):
# We recieved a response from the WS, match it up with the caller
# We received a response from the WS, match it up with the caller
if "id" in response and response["id"] in self.queues:
q = self.queues[response["id"]]
await q.put(response)
Expand Down Expand Up @@ -158,7 +158,7 @@ async def process_command(self, command, return_result, hass_timeout=0, suppress
# self.logger.info(f"Response: {response}")
# We got a valid response

# Set the AD response code and timeing
# Set the AD response code and timing
response["ad_status"] = "OK"
now = await self.AD.sched.get_now_ts()

Expand Down
2 changes: 1 addition & 1 deletion appdaemon/plugins/mqtt/mqttapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def listen_event(self, callback: Callable, event: str = None, **kwargs: Op

binary (bool, optional): If wanting the payload to be returned as binary, this should
be specified. If not given, AD will return the payload as decoded data. It should
be noted that it is not possible to have different apps receieve both binary and non-binary
be noted that it is not possible to have different apps receive both binary and non-binary
data on the same topic

Returns:
Expand Down
2 changes: 1 addition & 1 deletion appdaemon/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ async def loop(self): # noqa: C901
next_entries = self.get_next_entries()

elif self.timer_resetted is True:
# a timer was resetted, so need to recalculate next entries
# a timer was reset, so need to recalculate next entries
next_entries = self.get_next_entries()
self.timer_resetted = False

Expand Down
6 changes: 3 additions & 3 deletions appdaemon/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ async def async_worker(self, args): # noqa: C901
error_logger.warning("-" * 60)
error_logger.warning(
"Unexpected error in worker for App %s:", name)
error_logger.warning("Worker Ags: %s", args)
error_logger.warning("Worker Args: %s", args)
error_logger.warning("-" * 60)
error_logger.warning(traceback.format_exc())
error_logger.warning("-" * 60)
Expand Down Expand Up @@ -1176,7 +1176,7 @@ def worker(self): # noqa: C901
error_logger.warning("-" * 60)
error_logger.warning(
"Unexpected error in worker for App %s:", name)
error_logger.warning("Worker Ags: %s", args)
error_logger.warning("Worker Args: %s", args)
error_logger.warning("-" * 60)
error_logger.warning(traceback.format_exc())
error_logger.warning("-" * 60)
Expand Down Expand Up @@ -1250,7 +1250,7 @@ def report_callback_sig(self, name, type, funcref, args):
error_logger.warning("-" * 60)
error_logger.warning(
"Unexpected error in worker for App %s:", name)
error_logger.warning("Worker Ags: %s", args)
error_logger.warning("Worker Args: %s", args)
error_logger.warning("-" * 60)
error_logger.warning(traceback.format_exc())
error_logger.warning("-" * 60)
Expand Down
6 changes: 3 additions & 3 deletions appdaemon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def set_formater(self, obj, callback):
def __call__(self, value, **args):
for key in args:
setattr(self, key, args[key])
formater = self.types[type(value) if type(value) in self.types else object]
return formater(self, value, self.indent)
formatter = self.types[type(value) if type(value) in self.types else object]
return formatter(self, value, self.indent)

@staticmethod
def format_object(value, indent):
Expand Down Expand Up @@ -709,7 +709,7 @@ def _secret_yaml(loader, node):
def _env_var_yaml(loader, node):
env_var = node.value
if env_var not in os.environ:
raise ValueError("{} not found in as environment varibale".format(env_var))
raise ValueError("{} not found in as environment variable".format(env_var))

return os.environ[env_var]

Expand Down
2 changes: 1 addition & 1 deletion appdaemon/widgets/basefan/basefan.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function basefan(widget_id, url, skin, parameters)
else
//Fan is on
{
//turn main icon on & dispay speed selector
//turn main icon on & display speed selector
self.set_icon(self, "icon", self.icons.icon_active)
self.set_field(self, "icon_style", self.css.icon_style_active)

Expand Down
2 changes: 1 addition & 1 deletion conf/example_apps/ObjectTracker/general_app_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# state can be last time updated or time gone by since last update #
# check_last_update_time: checks when the last time was that a sensor was updated #
# save_last_update_time: saves the time that an object is updated to a file in a dir #
# you can define. the file wil have the name: lut_entity_id.py #
# you can define. the file will have the name: lut_entity_id.py #
# reformat_time: changed a timeformat from H:M:S to %H:%M:%S #
# #
# Rene Tode ( [email protected] ) #
Expand Down
2 changes: 1 addition & 1 deletion conf/example_dashboards/Modular/Test.dash
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ side_humidity:
#precision: 0
entity: sensor.side_humidity_corrected
#state_map:
# "49.0": Realy Cold
# "49.0": Really Cold

garage:
widget_type: cover
Expand Down
4 changes: 2 additions & 2 deletions conf/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Security:
insecure_message: "The following items are insecure :"
securing_message: "I have secured the following items: "
failed_message: "The following items failed to secure: "
alarm_cancel_message: ["Alarm has been cancelled", "uh oh, canceling alarm", "oh noes!"]
alarm_cancel_message: ["Alarm has been cancelled", "uh oh, canceling alarm", "oh no!"]
alarm_arm_message: "Alarm is armed"
alarm_disarm_message: "Alarm is disarmed"
alarm_entity: alarm_control_panel.ha_alarm
Expand Down Expand Up @@ -304,7 +304,7 @@ Security:
service: cover/close_cover
timeout: 20
#state_map:
# locked: "bannana"
# locked: "banana"
# unlocked: "fruitbat"
Garage Motion:
binary_sensor.garage_sensor:
Expand Down
2 changes: 1 addition & 1 deletion dockerStart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if [ -n "$ELEVATION" ]; then
fi

# Install packages specified by the end-user.
# - Recusively traverse $CONF directory, searching for non-empty system_packages.txt files
# - Recursively traverse $CONF directory, searching for non-empty system_packages.txt files
# - Use cat to read all the file contents, use echo to append whtespace " " char to the file content (to guard against the corner case where the user does not put a newline after the package name)
# - Use tr to substitute all newlines with " " char, to concatenate the name of all packages in a single line
# - Pipe to xargs, printing the executed command (-t), invoking `apk add` with the list of required packages. Do nothing if no system_packages.txt files is present (--no-run-if-empty)
Expand Down
Loading