From 327d3e306580fab7b56a127ef7e330d4c3e5ea60 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Sat, 17 Feb 2024 13:22:08 +0100 Subject: [PATCH] Replace black and flake8 with ruff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s simpler to use and has fewer dependencies. --- .github/workflows/ci.yaml | 23 +- .gitignore | 3 +- docs/conf.py | 22 +- poetry.lock | 322 ++++----------------- pyproject.toml | 18 +- setup.cfg | 2 - test_wakeonlan.py | 570 +++++++++++++++++++------------------- wakeonlan/__init__.py | 70 ++--- 8 files changed, 411 insertions(+), 619 deletions(-) delete mode 100644 setup.cfg diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0e14988..f7854b0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,17 +7,6 @@ on: tags: ['*'] jobs: - black: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - run: pip install poetry - - run: poetry install - - run: poetry run black --check . - build: runs-on: ubuntu-latest steps: @@ -32,7 +21,7 @@ jobs: name: dist path: dist/ - flake8: + mypy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -41,9 +30,9 @@ jobs: python-version: '3.10' - run: pip install poetry - run: poetry install - - run: poetry run flake8 + - run: poetry run mypy . - mypy: + ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -52,7 +41,8 @@ jobs: python-version: '3.10' - run: pip install poetry - run: poetry install - - run: poetry run mypy . + - run: poetry run ruff check + - run: poetry run ruff format --check unittest: runs-on: ubuntu-latest @@ -81,10 +71,9 @@ jobs: publish: runs-on: ubuntu-latest needs: - - black - build - - flake8 - mypy + - ruff - unittest if: startsWith(github.ref, 'refs/tags/') steps: diff --git a/.gitignore b/.gitignore index 3ec005b..64102dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .coverage *.lcov -.mypy_cache/ -__pycache__/ +*cache*/ _build/ dist/ diff --git a/docs/conf.py b/docs/conf.py index d932d01..498bebd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,31 +5,31 @@ import pkg_resources -project = "wakeonlan" +project = 'wakeonlan' _dist = pkg_resources.get_distribution(project) version = _dist.version release = _dist.version -copyright = "2012, Remco Haszing" +copyright = '2012, Remco Haszing' extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.intersphinx", - "sphinx.ext.napoleon", - "sphinx_rtd_theme", + 'sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'sphinx.ext.napoleon', + 'sphinx_rtd_theme', ] intersphinx_mapping = { - "python": ("https://docs.python.org/3.11", None), + 'python': ('https://docs.python.org/3.11', None), } -nitpick_ignore = [("py:class", "socket.AddressFamily")] +nitpick_ignore = [('py:class', 'socket.AddressFamily')] nitpicky = True -default_role = "any" +default_role = 'any' todo_include_todos = True -master_doc = "index" -html_theme = "sphinx_rtd_theme" +master_doc = 'index' +html_theme = 'sphinx_rtd_theme' diff --git a/poetry.lock b/poetry.lock index 7372c35..9b095f2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,76 +1,5 @@ # This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. -[[package]] -name = "black" -version = "23.7.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-23.7.0-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:5c4bc552ab52f6c1c506ccae05681fab58c3f72d59ae6e6639e8885e94fe2587"}, - {file = "black-23.7.0-cp310-cp310-macosx_10_16_universal2.whl", hash = "sha256:552513d5cd5694590d7ef6f46e1767a4df9af168d449ff767b13b084c020e63f"}, - {file = "black-23.7.0-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:86cee259349b4448adb4ef9b204bb4467aae74a386bce85d56ba4f5dc0da27be"}, - {file = "black-23.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:501387a9edcb75d7ae8a4412bb8749900386eaef258f1aefab18adddea1936bc"}, - {file = "black-23.7.0-cp310-cp310-win_amd64.whl", hash = "sha256:fb074d8b213749fa1d077d630db0d5f8cc3b2ae63587ad4116e8a436e9bbe995"}, - {file = "black-23.7.0-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:b5b0ee6d96b345a8b420100b7d71ebfdd19fab5e8301aff48ec270042cd40ac2"}, - {file = "black-23.7.0-cp311-cp311-macosx_10_16_universal2.whl", hash = "sha256:893695a76b140881531062d48476ebe4a48f5d1e9388177e175d76234ca247cd"}, - {file = "black-23.7.0-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:c333286dc3ddca6fdff74670b911cccedacb4ef0a60b34e491b8a67c833b343a"}, - {file = "black-23.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:831d8f54c3a8c8cf55f64d0422ee875eecac26f5f649fb6c1df65316b67c8926"}, - {file = "black-23.7.0-cp311-cp311-win_amd64.whl", hash = "sha256:7f3bf2dec7d541b4619b8ce526bda74a6b0bffc480a163fed32eb8b3c9aed8ad"}, - {file = "black-23.7.0-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:f9062af71c59c004cd519e2fb8f5d25d39e46d3af011b41ab43b9c74e27e236f"}, - {file = "black-23.7.0-cp38-cp38-macosx_10_16_universal2.whl", hash = "sha256:01ede61aac8c154b55f35301fac3e730baf0c9cf8120f65a9cd61a81cfb4a0c3"}, - {file = "black-23.7.0-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:327a8c2550ddc573b51e2c352adb88143464bb9d92c10416feb86b0f5aee5ff6"}, - {file = "black-23.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1c6022b86f83b632d06f2b02774134def5d4d4f1dac8bef16d90cda18ba28a"}, - {file = "black-23.7.0-cp38-cp38-win_amd64.whl", hash = "sha256:27eb7a0c71604d5de083757fbdb245b1a4fae60e9596514c6ec497eb63f95320"}, - {file = "black-23.7.0-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:8417dbd2f57b5701492cd46edcecc4f9208dc75529bcf76c514864e48da867d9"}, - {file = "black-23.7.0-cp39-cp39-macosx_10_16_universal2.whl", hash = "sha256:47e56d83aad53ca140da0af87678fb38e44fd6bc0af71eebab2d1f59b1acf1d3"}, - {file = "black-23.7.0-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:25cc308838fe71f7065df53aedd20327969d05671bac95b38fdf37ebe70ac087"}, - {file = "black-23.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:642496b675095d423f9b8448243336f8ec71c9d4d57ec17bf795b67f08132a91"}, - {file = "black-23.7.0-cp39-cp39-win_amd64.whl", hash = "sha256:ad0014efc7acf0bd745792bd0d8857413652979200ab924fbf239062adc12491"}, - {file = "black-23.7.0-py3-none-any.whl", hash = "sha256:9fd59d418c60c0348505f2ddf9609c1e1de8e7493eab96198fc89d9f865e7a96"}, - {file = "black-23.7.0.tar.gz", hash = "sha256:022a582720b0d9480ed82576c920a8c1dde97cc38ff11d8d8859b3bd6ca9eedb"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - -[[package]] -name = "click" -version = "8.1.6" -description = "Composable command line interface toolkit" -optional = false -python-versions = ">=3.7" -files = [ - {file = "click-8.1.6-py3-none-any.whl", hash = "sha256:fa244bb30b3b5ee2cae3da8f55c9e5e0c0e86093306301fb418eb9dc40fbded5"}, - {file = "click-8.1.6.tar.gz", hash = "sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd"}, -] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - -[[package]] -name = "colorama" -version = "0.4.6" -description = "Cross-platform colored terminal text." -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -files = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] - [[package]] name = "coverage" version = "7.2.7" @@ -146,97 +75,40 @@ tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.1 [package.extras] toml = ["tomli"] -[[package]] -name = "flake8" -version = "5.0.4" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.6.1" -files = [ - {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, - {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.9.0,<2.10.0" -pyflakes = ">=2.5.0,<2.6.0" - -[[package]] -name = "flake8-docstrings" -version = "1.7.0" -description = "Extension for flake8 which uses pydocstyle to check docstrings" -optional = false -python-versions = ">=3.7" -files = [ - {file = "flake8_docstrings-1.7.0-py2.py3-none-any.whl", hash = "sha256:51f2344026da083fc084166a9353f5082b01f72901df422f74b4d953ae88ac75"}, - {file = "flake8_docstrings-1.7.0.tar.gz", hash = "sha256:4c8cc748dc16e6869728699e5d0d685da9a10b0ea718e090b1ba088e67a941af"}, -] - -[package.dependencies] -flake8 = ">=3" -pydocstyle = ">=2.1" - -[[package]] -name = "flake8-import-order" -version = "0.18.2" -description = "Flake8 and pylama plugin that checks the ordering of import statements." -optional = false -python-versions = "*" -files = [ - {file = "flake8-import-order-0.18.2.tar.gz", hash = "sha256:e23941f892da3e0c09d711babbb0c73bc735242e9b216b726616758a920d900e"}, - {file = "flake8_import_order-0.18.2-py2.py3-none-any.whl", hash = "sha256:82ed59f1083b629b030ee9d3928d9e06b6213eb196fe745b3a7d4af2168130df"}, -] - -[package.dependencies] -pycodestyle = "*" -setuptools = "*" - -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - [[package]] name = "mypy" -version = "1.5.1" +version = "1.8.0" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ - {file = "mypy-1.5.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f33592ddf9655a4894aef22d134de7393e95fcbdc2d15c1ab65828eee5c66c70"}, - {file = "mypy-1.5.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:258b22210a4a258ccd077426c7a181d789d1121aca6db73a83f79372f5569ae0"}, - {file = "mypy-1.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9ec1f695f0c25986e6f7f8778e5ce61659063268836a38c951200c57479cc12"}, - {file = "mypy-1.5.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:abed92d9c8f08643c7d831300b739562b0a6c9fcb028d211134fc9ab20ccad5d"}, - {file = "mypy-1.5.1-cp310-cp310-win_amd64.whl", hash = "sha256:a156e6390944c265eb56afa67c74c0636f10283429171018446b732f1a05af25"}, - {file = "mypy-1.5.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6ac9c21bfe7bc9f7f1b6fae441746e6a106e48fc9de530dea29e8cd37a2c0cc4"}, - {file = "mypy-1.5.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:51cb1323064b1099e177098cb939eab2da42fea5d818d40113957ec954fc85f4"}, - {file = "mypy-1.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:596fae69f2bfcb7305808c75c00f81fe2829b6236eadda536f00610ac5ec2243"}, - {file = "mypy-1.5.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:32cb59609b0534f0bd67faebb6e022fe534bdb0e2ecab4290d683d248be1b275"}, - {file = "mypy-1.5.1-cp311-cp311-win_amd64.whl", hash = "sha256:159aa9acb16086b79bbb0016145034a1a05360626046a929f84579ce1666b315"}, - {file = "mypy-1.5.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f6b0e77db9ff4fda74de7df13f30016a0a663928d669c9f2c057048ba44f09bb"}, - {file = "mypy-1.5.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:26f71b535dfc158a71264e6dc805a9f8d2e60b67215ca0bfa26e2e1aa4d4d373"}, - {file = "mypy-1.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2fc3a600f749b1008cc75e02b6fb3d4db8dbcca2d733030fe7a3b3502902f161"}, - {file = "mypy-1.5.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:26fb32e4d4afa205b24bf645eddfbb36a1e17e995c5c99d6d00edb24b693406a"}, - {file = "mypy-1.5.1-cp312-cp312-win_amd64.whl", hash = "sha256:82cb6193de9bbb3844bab4c7cf80e6227d5225cc7625b068a06d005d861ad5f1"}, - {file = "mypy-1.5.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4a465ea2ca12804d5b34bb056be3a29dc47aea5973b892d0417c6a10a40b2d65"}, - {file = "mypy-1.5.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:9fece120dbb041771a63eb95e4896791386fe287fefb2837258925b8326d6160"}, - {file = "mypy-1.5.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d28ddc3e3dfeab553e743e532fb95b4e6afad51d4706dd22f28e1e5e664828d2"}, - {file = "mypy-1.5.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:57b10c56016adce71fba6bc6e9fd45d8083f74361f629390c556738565af8eeb"}, - {file = "mypy-1.5.1-cp38-cp38-win_amd64.whl", hash = "sha256:ff0cedc84184115202475bbb46dd99f8dcb87fe24d5d0ddfc0fe6b8575c88d2f"}, - {file = "mypy-1.5.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8f772942d372c8cbac575be99f9cc9d9fb3bd95c8bc2de6c01411e2c84ebca8a"}, - {file = "mypy-1.5.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:5d627124700b92b6bbaa99f27cbe615c8ea7b3402960f6372ea7d65faf376c14"}, - {file = "mypy-1.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:361da43c4f5a96173220eb53340ace68cda81845cd88218f8862dfb0adc8cddb"}, - {file = "mypy-1.5.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:330857f9507c24de5c5724235e66858f8364a0693894342485e543f5b07c8693"}, - {file = "mypy-1.5.1-cp39-cp39-win_amd64.whl", hash = "sha256:c543214ffdd422623e9fedd0869166c2f16affe4ba37463975043ef7d2ea8770"}, - {file = "mypy-1.5.1-py3-none-any.whl", hash = "sha256:f757063a83970d67c444f6e01d9550a7402322af3557ce7630d3c957386fa8f5"}, - {file = "mypy-1.5.1.tar.gz", hash = "sha256:b031b9601f1060bf1281feab89697324726ba0c0bae9d7cd7ab4b690940f0b92"}, + {file = "mypy-1.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:485a8942f671120f76afffff70f259e1cd0f0cfe08f81c05d8816d958d4577d3"}, + {file = "mypy-1.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:df9824ac11deaf007443e7ed2a4a26bebff98d2bc43c6da21b2b64185da011c4"}, + {file = "mypy-1.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2afecd6354bbfb6e0160f4e4ad9ba6e4e003b767dd80d85516e71f2e955ab50d"}, + {file = "mypy-1.8.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8963b83d53ee733a6e4196954502b33567ad07dfd74851f32be18eb932fb1cb9"}, + {file = "mypy-1.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:e46f44b54ebddbeedbd3d5b289a893219065ef805d95094d16a0af6630f5d410"}, + {file = "mypy-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:855fe27b80375e5c5878492f0729540db47b186509c98dae341254c8f45f42ae"}, + {file = "mypy-1.8.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4c886c6cce2d070bd7df4ec4a05a13ee20c0aa60cb587e8d1265b6c03cf91da3"}, + {file = "mypy-1.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d19c413b3c07cbecf1f991e2221746b0d2a9410b59cb3f4fb9557f0365a1a817"}, + {file = "mypy-1.8.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9261ed810972061388918c83c3f5cd46079d875026ba97380f3e3978a72f503d"}, + {file = "mypy-1.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:51720c776d148bad2372ca21ca29256ed483aa9a4cdefefcef49006dff2a6835"}, + {file = "mypy-1.8.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:52825b01f5c4c1c4eb0db253ec09c7aa17e1a7304d247c48b6f3599ef40db8bd"}, + {file = "mypy-1.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f5ac9a4eeb1ec0f1ccdc6f326bcdb464de5f80eb07fb38b5ddd7b0de6bc61e55"}, + {file = "mypy-1.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afe3fe972c645b4632c563d3f3eff1cdca2fa058f730df2b93a35e3b0c538218"}, + {file = "mypy-1.8.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:42c6680d256ab35637ef88891c6bd02514ccb7e1122133ac96055ff458f93fc3"}, + {file = "mypy-1.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:720a5ca70e136b675af3af63db533c1c8c9181314d207568bbe79051f122669e"}, + {file = "mypy-1.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:028cf9f2cae89e202d7b6593cd98db6759379f17a319b5faf4f9978d7084cdc6"}, + {file = "mypy-1.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4e6d97288757e1ddba10dd9549ac27982e3e74a49d8d0179fc14d4365c7add66"}, + {file = "mypy-1.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f1478736fcebb90f97e40aff11a5f253af890c845ee0c850fe80aa060a267c6"}, + {file = "mypy-1.8.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:42419861b43e6962a649068a61f4a4839205a3ef525b858377a960b9e2de6e0d"}, + {file = "mypy-1.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:2b5b6c721bd4aabaadead3a5e6fa85c11c6c795e0c81a7215776ef8afc66de02"}, + {file = "mypy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5c1538c38584029352878a0466f03a8ee7547d7bd9f641f57a0f3017a7c905b8"}, + {file = "mypy-1.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4ef4be7baf08a203170f29e89d79064463b7fc7a0908b9d0d5114e8009c3a259"}, + {file = "mypy-1.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7178def594014aa6c35a8ff411cf37d682f428b3b5617ca79029d8ae72f5402b"}, + {file = "mypy-1.8.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ab3c84fa13c04aeeeabb2a7f67a25ef5d77ac9d6486ff33ded762ef353aa5592"}, + {file = "mypy-1.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:99b00bc72855812a60d253420d8a2eae839b0afa4938f09f4d2aa9bb4654263a"}, + {file = "mypy-1.8.0-py3-none-any.whl", hash = "sha256:538fd81bb5e430cc1381a443971c0475582ff9f434c16cd46d2c66763ce85d9d"}, + {file = "mypy-1.8.0.tar.gz", hash = "sha256:6ff8b244d7085a0b425b56d327b480c3b29cafbd2eff27316a004f9a7391ae07"}, ] [package.dependencies] @@ -247,6 +119,7 @@ typing-extensions = ">=4.1.0" [package.extras] dmypy = ["psutil (>=4.0)"] install-types = ["pip"] +mypyc = ["setuptools (>=50)"] reports = ["lxml"] [[package]] @@ -261,106 +134,29 @@ files = [ ] [[package]] -name = "packaging" -version = "23.1" -description = "Core utilities for Python packages" -optional = false -python-versions = ">=3.7" -files = [ - {file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"}, - {file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"}, -] - -[[package]] -name = "pathspec" -version = "0.11.2" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.7" -files = [ - {file = "pathspec-0.11.2-py3-none-any.whl", hash = "sha256:1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20"}, - {file = "pathspec-0.11.2.tar.gz", hash = "sha256:e0d8d0ac2f12da61956eb2306b69f9469b42f4deb0f3cb6ed47b9cce9996ced3"}, -] - -[[package]] -name = "platformdirs" -version = "3.10.0" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +name = "ruff" +version = "0.2.1" +description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "platformdirs-3.10.0-py3-none-any.whl", hash = "sha256:d7c24979f292f916dc9cbf8648319032f551ea8c49a4c9bf2fb556a02070ec1d"}, - {file = "platformdirs-3.10.0.tar.gz", hash = "sha256:b45696dab2d7cc691a3226759c0d3b00c47c8b6e293d96f6436f733303f77f6d"}, -] - -[package.extras] -docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"] - -[[package]] -name = "pycodestyle" -version = "2.9.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, - {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, -] - -[[package]] -name = "pydocstyle" -version = "6.3.0" -description = "Python docstring style checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pydocstyle-6.3.0-py3-none-any.whl", hash = "sha256:118762d452a49d6b05e194ef344a55822987a462831ade91ec5c06fd2169d019"}, - {file = "pydocstyle-6.3.0.tar.gz", hash = "sha256:7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1"}, -] - -[package.dependencies] -snowballstemmer = ">=2.2.0" - -[package.extras] -toml = ["tomli (>=1.2.3)"] - -[[package]] -name = "pyflakes" -version = "2.5.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, - {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, -] - -[[package]] -name = "setuptools" -version = "68.1.0" -description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "setuptools-68.1.0-py3-none-any.whl", hash = "sha256:e13e1b0bc760e9b0127eda042845999b2f913e12437046e663b833aa96d89715"}, - {file = "setuptools-68.1.0.tar.gz", hash = "sha256:d59c97e7b774979a5ccb96388efc9eb65518004537e85d52e81eaee89ab6dd91"}, -] - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] -testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] - -[[package]] -name = "snowballstemmer" -version = "2.2.0" -description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." -optional = false -python-versions = "*" -files = [ - {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, - {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, + {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:dd81b911d28925e7e8b323e8d06951554655021df8dd4ac3045d7212ac4ba080"}, + {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:dc586724a95b7d980aa17f671e173df00f0a2eef23f8babbeee663229a938fec"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c92db7101ef5bfc18e96777ed7bc7c822d545fa5977e90a585accac43d22f18a"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:13471684694d41ae0f1e8e3a7497e14cd57ccb7dd72ae08d56a159d6c9c3e30e"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a11567e20ea39d1f51aebd778685582d4c56ccb082c1161ffc10f79bebe6df35"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:00a818e2db63659570403e44383ab03c529c2b9678ba4ba6c105af7854008105"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:be60592f9d218b52f03384d1325efa9d3b41e4c4d55ea022cd548547cc42cd2b"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fbd2288890b88e8aab4499e55148805b58ec711053588cc2f0196a44f6e3d855"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3ef052283da7dec1987bba8d8733051c2325654641dfe5877a4022108098683"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7022d66366d6fded4ba3889f73cd791c2d5621b2ccf34befc752cb0df70f5fad"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0a725823cb2a3f08ee743a534cb6935727d9e47409e4ad72c10a3faf042ad5ba"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0034d5b6323e6e8fe91b2a1e55b02d92d0b582d2953a2b37a67a2d7dedbb7acc"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e5cb5526d69bb9143c2e4d2a115d08ffca3d8e0fddc84925a7b54931c96f5c02"}, + {file = "ruff-0.2.1-py3-none-win32.whl", hash = "sha256:6b95ac9ce49b4fb390634d46d6ece32ace3acdd52814671ccaf20b7f60adb232"}, + {file = "ruff-0.2.1-py3-none-win_amd64.whl", hash = "sha256:e3affdcbc2afb6f5bd0eb3130139ceedc5e3f28d206fe49f63073cb9e65988e0"}, + {file = "ruff-0.2.1-py3-none-win_arm64.whl", hash = "sha256:efababa8e12330aa94a53e90a81eb6e2d55f348bc2e71adbf17d9cad23c03ee6"}, + {file = "ruff-0.2.1.tar.gz", hash = "sha256:3b42b5d8677cd0c72b99fcaf068ffc62abb5a19e71b4a3b9cfa50658a0af02f1"}, ] [[package]] @@ -376,27 +172,27 @@ files = [ [[package]] name = "types-setuptools" -version = "68.1.0.0" +version = "69.1.0.20240217" description = "Typing stubs for setuptools" optional = false -python-versions = "*" +python-versions = ">=3.8" files = [ - {file = "types-setuptools-68.1.0.0.tar.gz", hash = "sha256:2bc9b0c0818f77bdcec619970e452b320a423bb3ac074f5f8bc9300ac281c4ae"}, - {file = "types_setuptools-68.1.0.0-py3-none-any.whl", hash = "sha256:0c1618fb14850cb482adbec602bbb519c43f24942d66d66196bc7528320f33b1"}, + {file = "types-setuptools-69.1.0.20240217.tar.gz", hash = "sha256:243fecc8850b6f7fbfa84bab18ec93407046a4e91130056fd5a7caef971aaff9"}, + {file = "types_setuptools-69.1.0.20240217-py3-none-any.whl", hash = "sha256:8b60e14a652b48bda292801c5a0c1251c190ad587c295f7839e901634913bb96"}, ] [[package]] name = "typing-extensions" -version = "4.7.1" -description = "Backported and Experimental Type Hints for Python 3.7+" +version = "4.9.0" +description = "Backported and Experimental Type Hints for Python 3.8+" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, - {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, + {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, + {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, ] [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "ea6ff9ba19085111b386e22de2e41ce95797d96f2a60dd65c3f217be68902e4c" +content-hash = "74c93a8130750b8785bc13909607df54113a8fe9ee89667513ff5d38b7ec9339" diff --git a/pyproject.toml b/pyproject.toml index 0007ffa..d34736a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,12 +27,9 @@ wakeonlan = "wakeonlan:main" python = "^3.7" [tool.poetry.dev-dependencies] -black = { version = "*", python = ">= 3.8" } coverage = { version = "*", extras = ["toml"] } -flake8 = { version = "*", python = ">= 3.8" } -flake8-docstrings = { version = "*", python = ">= 3.8" } -flake8-import-order = { version = "*", python = ">= 3.8" } mypy = { version = "*", python = ">=3.8" } +ruff = { version = "*", python = ">=3.8" } types-setuptools = { version = "*", python = ">=3.8" } [tool.coverage.run] @@ -53,6 +50,19 @@ ignore_missing_imports = true strict_optional = true warn_return_any = true +[tool.ruff.format] +quote-style = "single" + +[tool.ruff.lint] +select = ["D", "E", "F", "I", "N", "W"] +ignore = ["D200", "D212", "E501", "W505"] + +[tool.ruff.lint.isort] +lines-after-imports = 2 + +[tool.ruff.lint.pydocstyle] +convention = "google" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ce9d392..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -ignore=D200,E203,E501 diff --git a/test_wakeonlan.py b/test_wakeonlan.py index c5fa6a9..059ca1a 100644 --- a/test_wakeonlan.py +++ b/test_wakeonlan.py @@ -6,9 +6,7 @@ import unittest from unittest import mock -from wakeonlan import create_magic_packet -from wakeonlan import main -from wakeonlan import send_magic_packet +from wakeonlan import create_magic_packet, main, send_magic_packet class TestCreateMagicPacket(unittest.TestCase): @@ -22,26 +20,26 @@ def test_no_separators(self) -> None: Test without separators. """ - result = create_magic_packet("000000000000") + result = create_magic_packet('000000000000') self.assertEqual( result, - b"\xff\xff\xff\xff\xff\xff" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00", + b'\xff\xff\xff\xff\xff\xff' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00', ) def test_colon(self) -> None: @@ -49,26 +47,26 @@ def test_colon(self) -> None: Test with a colon as separator. """ - result = create_magic_packet("01:23:45:67:89:ab") + result = create_magic_packet('01:23:45:67:89:ab') self.assertEqual( result, - b"\xff\xff\xff\xff\xff\xff" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab" - b"\x01#Eg\x89\xab", + b'\xff\xff\xff\xff\xff\xff' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab' + b'\x01#Eg\x89\xab', ) def test_hyphen(self) -> None: @@ -76,26 +74,26 @@ def test_hyphen(self) -> None: Test with a hyphen as separator. """ - result = create_magic_packet("ff-ff-ff-ff-ff-ff") + result = create_magic_packet('ff-ff-ff-ff-ff-ff') self.assertEqual( result, - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff", + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff', ) def test_dot(self) -> None: @@ -103,26 +101,26 @@ def test_dot(self) -> None: Test with a dot as separator. """ - result = create_magic_packet("ffff.ffff.ffff") + result = create_magic_packet('ffff.ffff.ffff') self.assertEqual( result, - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff" - b"\xff\xff\xff\xff\xff\xff", + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff', ) @@ -132,14 +130,14 @@ class TestSendMagicPacket(unittest.TestCase): """ - @mock.patch("socket.socket") + @mock.patch('socket.socket') def test_send_magic_packet(self, sock: mock.Mock) -> None: """ Test whether the magic packets are broadcasted to the specified network. """ send_magic_packet( - "133713371337", "00-00-00-00-00-00", ip_address="example.com", port=7 + '133713371337', '00-00-00-00-00-00', ip_address='example.com', port=7 ) self.assertEqual( sock.mock_calls, @@ -149,60 +147,60 @@ def test_send_magic_packet(self, sock: mock.Mock) -> None: mock.call() .__enter__() .setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1), - mock.call().__enter__().connect(("example.com", 7)), + mock.call().__enter__().connect(('example.com', 7)), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" + b'\xff\xff\xff\xff\xff\xff' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' ), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" + b'\xff\xff\xff\xff\xff\xff' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' ), mock.call().__exit__(None, None, None), ], ) - @mock.patch("socket.socket") + @mock.patch('socket.socket') def test_send_magic_packet_default(self, sock: mock.Mock) -> None: """ Test whether the magic packets are broadcasted using default values. """ - send_magic_packet("133713371337", "00-00-00-00-00-00") + send_magic_packet('133713371337', '00-00-00-00-00-00') self.assertEqual( sock.mock_calls, [ @@ -211,131 +209,131 @@ def test_send_magic_packet_default(self, sock: mock.Mock) -> None: mock.call() .__enter__() .setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1), - mock.call().__enter__().connect(("255.255.255.255", 9)), + mock.call().__enter__().connect(('255.255.255.255', 9)), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" + b'\xff\xff\xff\xff\xff\xff' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' ), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" + b'\xff\xff\xff\xff\xff\xff' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' ), mock.call().__exit__(None, None, None), ], ) - @mock.patch("socket.socket") + @mock.patch('socket.socket') def test_send_magic_packet_interface(self, sock: mock.Mock) -> None: """ Test whether the magic packets are broadcasted to the specified network via specified interface. """ send_magic_packet( - "133713371337", - "00-00-00-00-00-00", - ip_address="example.com", + '133713371337', + '00-00-00-00-00-00', + ip_address='example.com', port=7, - interface="192.168.0.2", + interface='192.168.0.2', ) self.assertEqual( sock.mock_calls, [ mock.call(socket.AF_INET, socket.SOCK_DGRAM), mock.call().__enter__(), - mock.call().__enter__().bind(("192.168.0.2", 0)), + mock.call().__enter__().bind(('192.168.0.2', 0)), mock.call() .__enter__() .setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1), - mock.call().__enter__().connect(("example.com", 7)), + mock.call().__enter__().connect(('example.com', 7)), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" + b'\xff\xff\xff\xff\xff\xff' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' ), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" + b'\xff\xff\xff\xff\xff\xff' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' ), mock.call().__exit__(None, None, None), ], ) - @mock.patch("socket.socket") + @mock.patch('socket.socket') def test_send_correct_af_chosen_with_ipv6_address(self, sock: mock.Mock) -> None: """ Test whether AF_INET6 automatically chosen when the `address_family` argument is not given. """ send_magic_packet( - "133713371337", - "00-00-00-00-00-00", - ip_address="fc00::", + '133713371337', + '00-00-00-00-00-00', + ip_address='fc00::', port=7, ) self.assertEqual( @@ -346,62 +344,62 @@ def test_send_correct_af_chosen_with_ipv6_address(self, sock: mock.Mock) -> None mock.call() .__enter__() .setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1), - mock.call().__enter__().connect(("fc00::", 7)), + mock.call().__enter__().connect(('fc00::', 7)), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" + b'\xff\xff\xff\xff\xff\xff' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' ), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" + b'\xff\xff\xff\xff\xff\xff' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' ), mock.call().__exit__(None, None, None), ], ) - @mock.patch("socket.socket") + @mock.patch('socket.socket') def test_send_with_explicit_ipv6_address(self, sock: mock.Mock) -> None: """ Test whether the given address family is used instead automatically it automatically. """ send_magic_packet( - "133713371337", - "00-00-00-00-00-00", - ip_address="example.com", + '133713371337', + '00-00-00-00-00-00', + ip_address='example.com', port=7, address_family=socket.AF_INET6, ) @@ -413,48 +411,48 @@ def test_send_with_explicit_ipv6_address(self, sock: mock.Mock) -> None: mock.call() .__enter__() .setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1), - mock.call().__enter__().connect(("example.com", 7)), + mock.call().__enter__().connect(('example.com', 7)), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" - b"\x137\x137\x137" + b'\xff\xff\xff\xff\xff\xff' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' + b'\x137\x137\x137' ), mock.call() .__enter__() .send( - b"\xff\xff\xff\xff\xff\xff" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" - b"\x00\x00\x00\x00\x00\x00" + b'\xff\xff\xff\xff\xff\xff' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00' ), mock.call().__exit__(None, None, None), ], @@ -467,45 +465,45 @@ class TestMain(unittest.TestCase): """ - @mock.patch("wakeonlan.send_magic_packet") + @mock.patch('wakeonlan.send_magic_packet') def test_main(self, send_magic_packet: mock.Mock) -> None: """ Test if processed arguments are passed to send_magic_packet. """ - main(["00:11:22:33:44:55", "-i", "host.example", "-p", "1337"]) + main(['00:11:22:33:44:55', '-i', 'host.example', '-p', '1337']) main( [ - "00:11:22:33:44:55", - "-i", - "host.example", - "-p", - "1337", - "-n", - "192.168.0.2", + '00:11:22:33:44:55', + '-i', + 'host.example', + '-p', + '1337', + '-n', + '192.168.0.2', ] ) - main(["00:11:22:33:44:55", "-i", "host.example", "-p", "1337", "-6"]) + main(['00:11:22:33:44:55', '-i', 'host.example', '-p', '1337', '-6']) self.assertEqual( send_magic_packet.mock_calls, [ mock.call( - "00:11:22:33:44:55", - ip_address="host.example", + '00:11:22:33:44:55', + ip_address='host.example', port=1337, interface=None, address_family=None, ), mock.call( - "00:11:22:33:44:55", - ip_address="host.example", + '00:11:22:33:44:55', + ip_address='host.example', port=1337, - interface="192.168.0.2", + interface='192.168.0.2', address_family=None, ), mock.call( - "00:11:22:33:44:55", - ip_address="host.example", + '00:11:22:33:44:55', + ip_address='host.example', port=1337, interface=None, address_family=socket.AF_INET6, @@ -514,5 +512,5 @@ def test_main(self, send_magic_packet: mock.Mock) -> None: ) -if __name__ == "__main__": +if __name__ == '__main__': unittest.main() diff --git a/wakeonlan/__init__.py b/wakeonlan/__init__.py index ca91696..412e064 100755 --- a/wakeonlan/__init__.py +++ b/wakeonlan/__init__.py @@ -6,11 +6,10 @@ import argparse import ipaddress import socket -from typing import List -from typing import Optional +import typing -BROADCAST_IP = "255.255.255.255" +BROADCAST_IP = '255.255.255.255' DEFAULT_PORT = 9 @@ -28,21 +27,21 @@ def create_magic_packet(macaddress: str) -> bytes: """ if len(macaddress) == 17: sep = macaddress[2] - macaddress = macaddress.replace(sep, "") + macaddress = macaddress.replace(sep, '') elif len(macaddress) == 14: sep = macaddress[4] - macaddress = macaddress.replace(sep, "") + macaddress = macaddress.replace(sep, '') if len(macaddress) != 12: - raise ValueError("Incorrect MAC address format") - return bytes.fromhex("F" * 12 + macaddress * 16) + raise ValueError('Incorrect MAC address format') + return bytes.fromhex('F' * 12 + macaddress * 16) def send_magic_packet( *macs: str, ip_address: str = BROADCAST_IP, port: int = DEFAULT_PORT, - interface: Optional[str] = None, - address_family: Optional[socket.AddressFamily] = None + interface: typing.Optional[str] = None, + address_family: typing.Optional[socket.AddressFamily] = None, ) -> None: """ Wake up computers having any of the given mac addresses. @@ -53,11 +52,14 @@ def send_magic_packet( macs: One or more macaddresses of machines to wake. Keyword Args: - ip_address: the ip address of the host to send the magic packet to. + ip_address: the ip address of the host to send the magic packet + to. port: the port of the host to send the magic packet to. - interface: the ip address of the network adapter to route the magic packet through. - address_family: the address family of the ip address to initiate connection with. - When not specificied, chosen automatically between IPv4 and IPv6. + interface: the ip address of the network adapter to route the + magic packet through. + address_family: the address family of the ip address to initiate + connection with. When not specificied, chosen automatically + between IPv4 and IPv6. """ packets = [create_magic_packet(mac) for mac in macs] @@ -83,45 +85,45 @@ def _is_ipv6_address(ip_address: str) -> bool: return False -def main(argv: Optional[List[str]] = None) -> None: +def main(argv: typing.Optional[typing.List[str]] = None) -> None: """ Run wake on lan as a CLI application. """ parser = argparse.ArgumentParser( - description="Wake one or more computers using the wake on lan protocol.", + description='Wake one or more computers using the wake on lan protocol.', formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) parser.add_argument( - "macs", - metavar="mac address", - nargs="+", - help="The mac addresses of the computers you are trying to wake.", + 'macs', + metavar='mac address', + nargs='+', + help='The mac addresses of the computers you are trying to wake.', ) parser.add_argument( - "-6", - dest="use_ipv6", - action="store_true", - help="To indicate if ipv6 should be used by default instead of ipv4.", + '-6', + dest='use_ipv6', + action='store_true', + help='To indicate if ipv6 should be used by default instead of ipv4.', ) parser.add_argument( - "-i", - metavar="ip", + '-i', + metavar='ip', default=BROADCAST_IP, - help="The ip address of the host to send the magic packet to.", + help='The ip address of the host to send the magic packet to.', ) parser.add_argument( - "-p", - metavar="port", + '-p', + metavar='port', type=int, default=DEFAULT_PORT, - help="The port of the host to send the magic packet to.", + help='The port of the host to send the magic packet to.', ) parser.add_argument( - "-n", - metavar="interface", + '-n', + metavar='interface', default=None, - help="The ip address of the network adapter to route the magic packet through.", + help='The ip address of the network adapter to route the magic packet through.', ) args = parser.parse_args(argv) send_magic_packet( @@ -129,9 +131,9 @@ def main(argv: Optional[List[str]] = None) -> None: ip_address=args.i, port=args.p, interface=args.n, - address_family=socket.AF_INET6 if args.use_ipv6 else None + address_family=socket.AF_INET6 if args.use_ipv6 else None, ) -if __name__ == "__main__": # pragma: nocover +if __name__ == '__main__': # pragma: nocover main()