diff --git a/.gitignore b/.gitignore index e1ab00a..dd30c86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,229 +1,35 @@ -# Ignore .hidden files -.* -# Ignore everything -* +#------- Package & Cache Files ------- +*.egg-info +__pycache__ +node_modules +.vite -!.github/ -!.github/** - -!.codecov.yml -!.coveragerc - -!.gitattributes -!.gitignore -!.gitempty - -!CHANGELOG.md -!CONTRIBUTING.md -!LICENSE.md -!SECURITY.md -!CODE_OF_CONDUCT.md -!README.md -!README.rst -!MANIFEST.in -!SUPPORT.md - -!mkdocs.rtd.yml -!mkdocs.web.yml -!.pre-commit-config.yaml -!.gitleaks.toml -!.prettierrc.yml -!.yamllint - - -# PROJECT - -!pyproject.toml -!uv.lock - -!amqtt/ -!amqtt/** - -!docs/ -!docs/** -!samples/ -!samples/** -!scripts/ -scripts/* -!scripts/*.sh - -!tests/ -!tests/** -tests/**/test.db -.DS_Store -# Created by https://www.toptal.com/developers/gitignore/api/python -# Edit at https://www.toptal.com/developers/gitignore?templates=python - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: +#------- Environment Files ------- .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env .venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ -# Spyder project settings -.spyderproject -.spyproject +#------- Git Files ------- +BASE +LOCAL +*.orig +REMOTE -# Rope project settings -.ropeproject +#------- OS Files ------- +.DS_Store -# mkdocs documentation -/site +#------ Database Files ------- +*.sqlite3 +*.db -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json +#------ IDE ------ +.idea +.vscode/ -# Pyre type checker -.pyre/ -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -### Python Patch ### -# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration -poetry.toml - -# ruff -.ruff_cache/ - -# LSP config files -pyrightconfig.json - -# End of https://www.toptal.com/developers/gitignore/api/python +#----- Built Directory & Files------ +.coverage +dist/ +site/ +_build/ +.hypothesis/ +coverage.xml diff --git a/amqtt/mqtt/protocol/handler.py b/amqtt/mqtt/protocol/handler.py index 6bea05f..2f24c3e 100644 --- a/amqtt/mqtt/protocol/handler.py +++ b/amqtt/mqtt/protocol/handler.py @@ -152,11 +152,11 @@ class ProtocolHandler: if self.writer is not None: await self.writer.close() except asyncio.CancelledError: - self.logger.debug("Writer close was cancelled.") - except TimeoutError as e: - self.logger.debug(f"Writer close operation timed out: {e}.") - except OSError as e: - self.logger.debug(f"Writer close failed due to I/O error: {e}") + self.logger.debug("Writer close was cancelled.", exc_info=True) + except TimeoutError: + self.logger.debug("Writer close operation timed out.", exc_info=True) + except OSError: + self.logger.debug("Writer close failed due to I/O error.", exc_info=True) def _stop_waiters(self) -> None: self.logger.debug(f"Stopping {len(self._puback_waiters)} puback waiters") diff --git a/amqtt/plugins/manager.py b/amqtt/plugins/manager.py index c2f6cc6..e1db79a 100644 --- a/amqtt/plugins/manager.py +++ b/amqtt/plugins/manager.py @@ -86,8 +86,8 @@ class PluginManager: plugin_context.logger = self.logger.getChild(ep.name) obj = plugin(plugin_context) return Plugin(ep.name, ep, obj) - except ImportError as ie: - self.logger.warning(f"Plugin {ep!r} import failed: {ie}") + except ImportError: + self.logger.warning(f"Plugin {ep!r} import failed", exc_info=True) return None diff --git a/docs/license.rst b/docs/license.rst deleted file mode 100644 index 7361a9f..0000000 --- a/docs/license.rst +++ /dev/null @@ -1,4 +0,0 @@ -License -------- - -.. literalinclude:: ../LICENSE.md diff --git a/samples/client_publish.py b/samples/client_publish.py index 57bcf58..9b0f4f6 100644 --- a/samples/client_publish.py +++ b/samples/client_publish.py @@ -43,8 +43,8 @@ async def test_coro2() -> None: await C.publish("a/b", b"TEST MESSAGE WITH QOS_2", qos=0x02) logger.info("messages published") await C.disconnect() - except ConnectError as ce: - logger.exception(f"Connection failed: {ce}") + except ConnectError: + logger.exception(f"Connection failed", exc_info=True) asyncio.get_event_loop().stop() diff --git a/samples/client_publish_acl.py b/samples/client_publish_acl.py index 0a1cbb6..2ecf33e 100644 --- a/samples/client_publish_acl.py +++ b/samples/client_publish_acl.py @@ -27,7 +27,7 @@ async def test_coro() -> None: logger.info("messages published") await C.disconnect() except ConnectError as ce: - logger.exception(f"Connection failed: {ce}") + logger.exception("Connection failed") asyncio.get_event_loop().stop() diff --git a/samples/client_subscribe.py b/samples/client_subscribe.py index 0a29efb..3d175d6 100644 --- a/samples/client_subscribe.py +++ b/samples/client_subscribe.py @@ -30,8 +30,8 @@ async def uptime_coro() -> None: await C.unsubscribe(["$SYS/broker/uptime", "$SYS/broker/load/#"]) logger.info("UnSubscribed") await C.disconnect() - except ClientError as ce: - logger.exception(f"Client exception: {ce}") + except ClientError: + logger.exception("Client exception") if __name__ == "__main__": diff --git a/samples/client_subscribe_acl.py b/samples/client_subscribe_acl.py index aa69435..1810b6b 100644 --- a/samples/client_subscribe_acl.py +++ b/samples/client_subscribe_acl.py @@ -35,7 +35,7 @@ async def uptime_coro() -> None: logger.info("UnSubscribed") await C.disconnect() except ClientError as ce: - logger.exception(f"Client exception: {ce}") + logger.exception("Client exception") if __name__ == "__main__":