From d560eba2fb3655ed1eb2c3c15e8b71e1233e2865 Mon Sep 17 00:00:00 2001 From: Lari Liuhamo Date: Sat, 28 Oct 2023 21:09:19 +0300 Subject: [PATCH] [PATCH] Updated Tox and Ruff rules --- .github/workflows/unit_tests.yml | 42 ++-- escapyde/__init__.py | 4 - escapyde/examples/__init__.py | 0 poetry.lock | 174 ++++++++-------- pyproject.toml | 212 +++++++++++--------- src/escapyde/__init__.py | 4 + {escapyde => src/escapyde}/ansi.py | 36 ++-- {escapyde => src/escapyde}/colours.py | 2 +- {escapyde => src/escapyde}/config.py | 2 +- src/escapyde/examples/__init__.py | 1 + {escapyde => src/escapyde}/examples/text.py | 2 +- {escapyde => src/escapyde}/validators.py | 11 +- tests/conftest.py | 20 +- tests/test_ansi.py | 14 +- tests/test_colours.py | 20 +- 15 files changed, 275 insertions(+), 269 deletions(-) delete mode 100644 escapyde/__init__.py delete mode 100644 escapyde/examples/__init__.py create mode 100644 src/escapyde/__init__.py rename {escapyde => src/escapyde}/ansi.py (84%) rename {escapyde => src/escapyde}/colours.py (98%) rename {escapyde => src/escapyde}/config.py (93%) create mode 100644 src/escapyde/examples/__init__.py rename {escapyde => src/escapyde}/examples/text.py (98%) rename {escapyde => src/escapyde}/validators.py (85%) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index de0d185..a5f943b 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -7,7 +7,7 @@ name: Unit tests -on: [ push ] +on: [ push, pull_request ] jobs: test: @@ -15,29 +15,20 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] - tox-env: [ - py39, - py310, - py311, - pypy3 + python-version: [ + '3.10', + '3.11', + # 'pypy-3.10' ] - include: - - tox-env: py39 - python-version: '3.9' - - tox-env: py310 - python-version: '3.10' - - tox-env: py311 - python-version: '3.11' - - tox-env: pypy3 - python-version: pypy-3.9 - - exclude: - - os: windows-latest - tox-env: pypy3 - - os: macos-latest - tox-env: pypy3 + + # exclude: + # - os: windows-latest + # python-version: 'pypy-3.10' + # - os: macos-latest + # python-version: 'pypy-3.10' + env: - TOXENV: ${{ matrix.tox-env }} + PYTHON_VERSION: ${{ matrix.python-version }} steps: @@ -62,16 +53,17 @@ jobs: poetry run tox env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PLATFORM: ${{ matrix.os }} - name: Upload Results to CodeCov if: success() - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 with: - env_vars: TOXENV + env_vars: PYTHON_VERSION fail_ci_if_error: false files: ./tests/reports/coverage-html/index.html,./tests/reports/coverage.xml flags: unittests - name: ${{ matrix.os }}-${{ matrix.tox-env }} + name: "${{ matrix.os }} - Python ${{ matrix.python-version }}" token: ${{ secrets.CODECOV_TOKEN }} diff --git a/escapyde/__init__.py b/escapyde/__init__.py deleted file mode 100644 index 9c43632..0000000 --- a/escapyde/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -"""A library for simplifying ANSI escape sequences in Python""" - -from escapyde.ansi import * -from escapyde.colours import * diff --git a/escapyde/examples/__init__.py b/escapyde/examples/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/poetry.lock b/poetry.lock index 5c2a102..2bc213b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,13 +2,13 @@ [[package]] name = "cachetools" -version = "5.3.1" +version = "5.3.2" description = "Extensible memoizing collections and decorators" optional = false python-versions = ">=3.7" files = [ - {file = "cachetools-5.3.1-py3-none-any.whl", hash = "sha256:95ef631eeaea14ba2e36f06437f36463aac3a096799e876ee55e5cdccb102590"}, - {file = "cachetools-5.3.1.tar.gz", hash = "sha256:dce83f2d9b4e1f732a8cd44af8e8fab2dbe46201467fc98b3ef8f269092bf62b"}, + {file = "cachetools-5.3.2-py3-none-any.whl", hash = "sha256:861f35a13a451f94e301ce2bec7cac63e881232ccce7ed67fab9b5df4d3beaa1"}, + {file = "cachetools-5.3.2.tar.gz", hash = "sha256:086ee420196f7b2ab9ca2db2520aca326318b68fe5ba8bc4d49cca91add450f2"}, ] [[package]] @@ -35,71 +35,63 @@ files = [ [[package]] name = "coverage" -version = "7.2.7" +version = "7.3.2" description = "Code coverage measurement for Python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "coverage-7.2.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d39b5b4f2a66ccae8b7263ac3c8170994b65266797fb96cbbfd3fb5b23921db8"}, - {file = "coverage-7.2.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6d040ef7c9859bb11dfeb056ff5b3872436e3b5e401817d87a31e1750b9ae2fb"}, - {file = "coverage-7.2.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ba90a9563ba44a72fda2e85302c3abc71c5589cea608ca16c22b9804262aaeb6"}, - {file = "coverage-7.2.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e7d9405291c6928619403db1d10bd07888888ec1abcbd9748fdaa971d7d661b2"}, - {file = "coverage-7.2.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:31563e97dae5598556600466ad9beea39fb04e0229e61c12eaa206e0aa202063"}, - {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:ebba1cd308ef115925421d3e6a586e655ca5a77b5bf41e02eb0e4562a111f2d1"}, - {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:cb017fd1b2603ef59e374ba2063f593abe0fc45f2ad9abdde5b4d83bd922a353"}, - {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d62a5c7dad11015c66fbb9d881bc4caa5b12f16292f857842d9d1871595f4495"}, - {file = "coverage-7.2.7-cp310-cp310-win32.whl", hash = "sha256:ee57190f24fba796e36bb6d3aa8a8783c643d8fa9760c89f7a98ab5455fbf818"}, - {file = "coverage-7.2.7-cp310-cp310-win_amd64.whl", hash = "sha256:f75f7168ab25dd93110c8a8117a22450c19976afbc44234cbf71481094c1b850"}, - {file = "coverage-7.2.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:06a9a2be0b5b576c3f18f1a241f0473575c4a26021b52b2a85263a00f034d51f"}, - {file = "coverage-7.2.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5baa06420f837184130752b7c5ea0808762083bf3487b5038d68b012e5937dbe"}, - {file = "coverage-7.2.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fdec9e8cbf13a5bf63290fc6013d216a4c7232efb51548594ca3631a7f13c3a3"}, - {file = "coverage-7.2.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:52edc1a60c0d34afa421c9c37078817b2e67a392cab17d97283b64c5833f427f"}, - {file = "coverage-7.2.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63426706118b7f5cf6bb6c895dc215d8a418d5952544042c8a2d9fe87fcf09cb"}, - {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:afb17f84d56068a7c29f5fa37bfd38d5aba69e3304af08ee94da8ed5b0865833"}, - {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:48c19d2159d433ccc99e729ceae7d5293fbffa0bdb94952d3579983d1c8c9d97"}, - {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:0e1f928eaf5469c11e886fe0885ad2bf1ec606434e79842a879277895a50942a"}, - {file = "coverage-7.2.7-cp311-cp311-win32.whl", hash = "sha256:33d6d3ea29d5b3a1a632b3c4e4f4ecae24ef170b0b9ee493883f2df10039959a"}, - {file = "coverage-7.2.7-cp311-cp311-win_amd64.whl", hash = "sha256:5b7540161790b2f28143191f5f8ec02fb132660ff175b7747b95dcb77ac26562"}, - {file = "coverage-7.2.7-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f2f67fe12b22cd130d34d0ef79206061bfb5eda52feb6ce0dba0644e20a03cf4"}, - {file = "coverage-7.2.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a342242fe22407f3c17f4b499276a02b01e80f861f1682ad1d95b04018e0c0d4"}, - {file = "coverage-7.2.7-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:171717c7cb6b453aebac9a2ef603699da237f341b38eebfee9be75d27dc38e01"}, - {file = "coverage-7.2.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49969a9f7ffa086d973d91cec8d2e31080436ef0fb4a359cae927e742abfaaa6"}, - {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:b46517c02ccd08092f4fa99f24c3b83d8f92f739b4657b0f146246a0ca6a831d"}, - {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:a3d33a6b3eae87ceaefa91ffdc130b5e8536182cd6dfdbfc1aa56b46ff8c86de"}, - {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:976b9c42fb2a43ebf304fa7d4a310e5f16cc99992f33eced91ef6f908bd8f33d"}, - {file = "coverage-7.2.7-cp312-cp312-win32.whl", hash = "sha256:8de8bb0e5ad103888d65abef8bca41ab93721647590a3f740100cd65c3b00511"}, - {file = "coverage-7.2.7-cp312-cp312-win_amd64.whl", hash = "sha256:9e31cb64d7de6b6f09702bb27c02d1904b3aebfca610c12772452c4e6c21a0d3"}, - {file = "coverage-7.2.7-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:58c2ccc2f00ecb51253cbe5d8d7122a34590fac9646a960d1430d5b15321d95f"}, - {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d22656368f0e6189e24722214ed8d66b8022db19d182927b9a248a2a8a2f67eb"}, - {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a895fcc7b15c3fc72beb43cdcbdf0ddb7d2ebc959edac9cef390b0d14f39f8a9"}, - {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e84606b74eb7de6ff581a7915e2dab7a28a0517fbe1c9239eb227e1354064dcd"}, - {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:0a5f9e1dbd7fbe30196578ca36f3fba75376fb99888c395c5880b355e2875f8a"}, - {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:419bfd2caae268623dd469eff96d510a920c90928b60f2073d79f8fe2bbc5959"}, - {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:2aee274c46590717f38ae5e4650988d1af340fe06167546cc32fe2f58ed05b02"}, - {file = "coverage-7.2.7-cp37-cp37m-win32.whl", hash = "sha256:61b9a528fb348373c433e8966535074b802c7a5d7f23c4f421e6c6e2f1697a6f"}, - {file = "coverage-7.2.7-cp37-cp37m-win_amd64.whl", hash = "sha256:b1c546aca0ca4d028901d825015dc8e4d56aac4b541877690eb76490f1dc8ed0"}, - {file = "coverage-7.2.7-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:54b896376ab563bd38453cecb813c295cf347cf5906e8b41d340b0321a5433e5"}, - {file = "coverage-7.2.7-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:3d376df58cc111dc8e21e3b6e24606b5bb5dee6024f46a5abca99124b2229ef5"}, - {file = "coverage-7.2.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e330fc79bd7207e46c7d7fd2bb4af2963f5f635703925543a70b99574b0fea9"}, - {file = "coverage-7.2.7-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e9d683426464e4a252bf70c3498756055016f99ddaec3774bf368e76bbe02b6"}, - {file = "coverage-7.2.7-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d13c64ee2d33eccf7437961b6ea7ad8673e2be040b4f7fd4fd4d4d28d9ccb1e"}, - {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b7aa5f8a41217360e600da646004f878250a0d6738bcdc11a0a39928d7dc2050"}, - {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:8fa03bce9bfbeeef9f3b160a8bed39a221d82308b4152b27d82d8daa7041fee5"}, - {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:245167dd26180ab4c91d5e1496a30be4cd721a5cf2abf52974f965f10f11419f"}, - {file = "coverage-7.2.7-cp38-cp38-win32.whl", hash = "sha256:d2c2db7fd82e9b72937969bceac4d6ca89660db0a0967614ce2481e81a0b771e"}, - {file = "coverage-7.2.7-cp38-cp38-win_amd64.whl", hash = "sha256:2e07b54284e381531c87f785f613b833569c14ecacdcb85d56b25c4622c16c3c"}, - {file = "coverage-7.2.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:537891ae8ce59ef63d0123f7ac9e2ae0fc8b72c7ccbe5296fec45fd68967b6c9"}, - {file = "coverage-7.2.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:06fb182e69f33f6cd1d39a6c597294cff3143554b64b9825d1dc69d18cc2fff2"}, - {file = "coverage-7.2.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:201e7389591af40950a6480bd9edfa8ed04346ff80002cec1a66cac4549c1ad7"}, - {file = "coverage-7.2.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f6951407391b639504e3b3be51b7ba5f3528adbf1a8ac3302b687ecababf929e"}, - {file = "coverage-7.2.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f48351d66575f535669306aa7d6d6f71bc43372473b54a832222803eb956fd1"}, - {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b29019c76039dc3c0fd815c41392a044ce555d9bcdd38b0fb60fb4cd8e475ba9"}, - {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:81c13a1fc7468c40f13420732805a4c38a105d89848b7c10af65a90beff25250"}, - {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:975d70ab7e3c80a3fe86001d8751f6778905ec723f5b110aed1e450da9d4b7f2"}, - {file = "coverage-7.2.7-cp39-cp39-win32.whl", hash = "sha256:7ee7d9d4822c8acc74a5e26c50604dff824710bc8de424904c0982e25c39c6cb"}, - {file = "coverage-7.2.7-cp39-cp39-win_amd64.whl", hash = "sha256:eb393e5ebc85245347950143969b241d08b52b88a3dc39479822e073a1a8eb27"}, - {file = "coverage-7.2.7-pp37.pp38.pp39-none-any.whl", hash = "sha256:b7b4c971f05e6ae490fef852c218b0e79d4e52f79ef0c8475566584a8fb3e01d"}, - {file = "coverage-7.2.7.tar.gz", hash = "sha256:924d94291ca674905fe9481f12294eb11f2d3d3fd1adb20314ba89e94f44ed59"}, + {file = "coverage-7.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d872145f3a3231a5f20fd48500274d7df222e291d90baa2026cc5152b7ce86bf"}, + {file = "coverage-7.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:310b3bb9c91ea66d59c53fa4989f57d2436e08f18fb2f421a1b0b6b8cc7fffda"}, + {file = "coverage-7.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f47d39359e2c3779c5331fc740cf4bce6d9d680a7b4b4ead97056a0ae07cb49a"}, + {file = "coverage-7.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aa72dbaf2c2068404b9870d93436e6d23addd8bbe9295f49cbca83f6e278179c"}, + {file = "coverage-7.3.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:beaa5c1b4777f03fc63dfd2a6bd820f73f036bfb10e925fce067b00a340d0f3f"}, + {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:dbc1b46b92186cc8074fee9d9fbb97a9dd06c6cbbef391c2f59d80eabdf0faa6"}, + {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:315a989e861031334d7bee1f9113c8770472db2ac484e5b8c3173428360a9148"}, + {file = "coverage-7.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d1bc430677773397f64a5c88cb522ea43175ff16f8bfcc89d467d974cb2274f9"}, + {file = "coverage-7.3.2-cp310-cp310-win32.whl", hash = "sha256:a889ae02f43aa45032afe364c8ae84ad3c54828c2faa44f3bfcafecb5c96b02f"}, + {file = "coverage-7.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:c0ba320de3fb8c6ec16e0be17ee1d3d69adcda99406c43c0409cb5c41788a611"}, + {file = "coverage-7.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ac8c802fa29843a72d32ec56d0ca792ad15a302b28ca6203389afe21f8fa062c"}, + {file = "coverage-7.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:89a937174104339e3a3ffcf9f446c00e3a806c28b1841c63edb2b369310fd074"}, + {file = "coverage-7.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e267e9e2b574a176ddb983399dec325a80dbe161f1a32715c780b5d14b5f583a"}, + {file = "coverage-7.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2443cbda35df0d35dcfb9bf8f3c02c57c1d6111169e3c85fc1fcc05e0c9f39a3"}, + {file = "coverage-7.3.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4175e10cc8dda0265653e8714b3174430b07c1dca8957f4966cbd6c2b1b8065a"}, + {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0cbf38419fb1a347aaf63481c00f0bdc86889d9fbf3f25109cf96c26b403fda1"}, + {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:5c913b556a116b8d5f6ef834038ba983834d887d82187c8f73dec21049abd65c"}, + {file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1981f785239e4e39e6444c63a98da3a1db8e971cb9ceb50a945ba6296b43f312"}, + {file = "coverage-7.3.2-cp311-cp311-win32.whl", hash = "sha256:43668cabd5ca8258f5954f27a3aaf78757e6acf13c17604d89648ecc0cc66640"}, + {file = "coverage-7.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:e10c39c0452bf6e694511c901426d6b5ac005acc0f78ff265dbe36bf81f808a2"}, + {file = "coverage-7.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:4cbae1051ab791debecc4a5dcc4a1ff45fc27b91b9aee165c8a27514dd160836"}, + {file = "coverage-7.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12d15ab5833a997716d76f2ac1e4b4d536814fc213c85ca72756c19e5a6b3d63"}, + {file = "coverage-7.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3c7bba973ebee5e56fe9251300c00f1579652587a9f4a5ed8404b15a0471f216"}, + {file = "coverage-7.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe494faa90ce6381770746077243231e0b83ff3f17069d748f645617cefe19d4"}, + {file = "coverage-7.3.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f6e9589bd04d0461a417562649522575d8752904d35c12907d8c9dfeba588faf"}, + {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d51ac2a26f71da1b57f2dc81d0e108b6ab177e7d30e774db90675467c847bbdf"}, + {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:99b89d9f76070237975b315b3d5f4d6956ae354a4c92ac2388a5695516e47c84"}, + {file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:fa28e909776dc69efb6ed975a63691bc8172b64ff357e663a1bb06ff3c9b589a"}, + {file = "coverage-7.3.2-cp312-cp312-win32.whl", hash = "sha256:289fe43bf45a575e3ab10b26d7b6f2ddb9ee2dba447499f5401cfb5ecb8196bb"}, + {file = "coverage-7.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:7dbc3ed60e8659bc59b6b304b43ff9c3ed858da2839c78b804973f613d3e92ed"}, + {file = "coverage-7.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f94b734214ea6a36fe16e96a70d941af80ff3bfd716c141300d95ebc85339738"}, + {file = "coverage-7.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:af3d828d2c1cbae52d34bdbb22fcd94d1ce715d95f1a012354a75e5913f1bda2"}, + {file = "coverage-7.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:630b13e3036e13c7adc480ca42fa7afc2a5d938081d28e20903cf7fd687872e2"}, + {file = "coverage-7.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c9eacf273e885b02a0273bb3a2170f30e2d53a6d53b72dbe02d6701b5296101c"}, + {file = "coverage-7.3.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8f17966e861ff97305e0801134e69db33b143bbfb36436efb9cfff6ec7b2fd9"}, + {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b4275802d16882cf9c8b3d057a0839acb07ee9379fa2749eca54efbce1535b82"}, + {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:72c0cfa5250f483181e677ebc97133ea1ab3eb68645e494775deb6a7f6f83901"}, + {file = "coverage-7.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:cb536f0dcd14149425996821a168f6e269d7dcd2c273a8bff8201e79f5104e76"}, + {file = "coverage-7.3.2-cp38-cp38-win32.whl", hash = "sha256:307adb8bd3abe389a471e649038a71b4eb13bfd6b7dd9a129fa856f5c695cf92"}, + {file = "coverage-7.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:88ed2c30a49ea81ea3b7f172e0269c182a44c236eb394718f976239892c0a27a"}, + {file = "coverage-7.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b631c92dfe601adf8f5ebc7fc13ced6bb6e9609b19d9a8cd59fa47c4186ad1ce"}, + {file = "coverage-7.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:d3d9df4051c4a7d13036524b66ecf7a7537d14c18a384043f30a303b146164e9"}, + {file = "coverage-7.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f7363d3b6a1119ef05015959ca24a9afc0ea8a02c687fe7e2d557705375c01f"}, + {file = "coverage-7.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2f11cc3c967a09d3695d2a6f03fb3e6236622b93be7a4b5dc09166a861be6d25"}, + {file = "coverage-7.3.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:149de1d2401ae4655c436a3dced6dd153f4c3309f599c3d4bd97ab172eaf02d9"}, + {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:3a4006916aa6fee7cd38db3bfc95aa9c54ebb4ffbfc47c677c8bba949ceba0a6"}, + {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9028a3871280110d6e1aa2df1afd5ef003bab5fb1ef421d6dc748ae1c8ef2ebc"}, + {file = "coverage-7.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9f805d62aec8eb92bab5b61c0f07329275b6f41c97d80e847b03eb894f38d083"}, + {file = "coverage-7.3.2-cp39-cp39-win32.whl", hash = "sha256:d1c88ec1a7ff4ebca0219f5b1ef863451d828cccf889c173e1253aa84b1e07ce"}, + {file = "coverage-7.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b4767da59464bb593c07afceaddea61b154136300881844768037fd5e859353f"}, + {file = "coverage-7.3.2-pp38.pp39.pp310-none-any.whl", hash = "sha256:ae97af89f0fbf373400970c0a21eef5aa941ffeed90aee43650b81f7d7f47637"}, + {file = "coverage-7.3.2.tar.gz", hash = "sha256:be32ad29341b0170e795ca590e1c07e81fc061cb5b10c74ce7203491484404ef"}, ] [package.dependencies] @@ -121,13 +113,13 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.1.1" +version = "1.1.3" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.1.1-py3-none-any.whl", hash = "sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e"}, - {file = "exceptiongroup-1.1.1.tar.gz", hash = "sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785"}, + {file = "exceptiongroup-1.1.3-py3-none-any.whl", hash = "sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3"}, + {file = "exceptiongroup-1.1.3.tar.gz", hash = "sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9"}, ] [package.extras] @@ -135,21 +127,19 @@ test = ["pytest (>=6)"] [[package]] name = "filelock" -version = "3.12.3" +version = "3.13.0" description = "A platform independent file lock." optional = false python-versions = ">=3.8" files = [ - {file = "filelock-3.12.3-py3-none-any.whl", hash = "sha256:f067e40ccc40f2b48395a80fcbd4728262fab54e232e090a4063ab804179efeb"}, - {file = "filelock-3.12.3.tar.gz", hash = "sha256:0ecc1dd2ec4672a10c8550a8182f1bd0c0a5088470ecd5a125e45f49472fac3d"}, + {file = "filelock-3.13.0-py3-none-any.whl", hash = "sha256:a552f4fde758f4eab33191e9548f671970f8b06d436d31388c9aa1e5861a710f"}, + {file = "filelock-3.13.0.tar.gz", hash = "sha256:63c6052c82a1a24c873a549fbd39a26982e8f35a3016da231ead11a5be9dad44"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.7.1", markers = "python_version < \"3.11\""} - [package.extras] -docs = ["furo (>=2023.7.26)", "sphinx (>=7.1.2)", "sphinx-autodoc-typehints (>=1.24)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3)", "diff-cover (>=7.7)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest-timeout (>=2.1)"] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +typing = ["typing-extensions (>=4.8)"] [[package]] name = "iniconfig" @@ -221,24 +211,24 @@ files = [ [[package]] name = "packaging" -version = "23.1" +version = "23.2" 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"}, + {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, + {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, ] [[package]] name = "platformdirs" -version = "3.10.0" +version = "3.11.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." 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"}, + {file = "platformdirs-3.11.0-py3-none-any.whl", hash = "sha256:e9d171d00af68be50e9202731309c4e658fd8bc76f55c11c7dd760d023bda68e"}, + {file = "platformdirs-3.11.0.tar.gz", hash = "sha256:cf8ee52a3afdb965072dcc652433e0c7e3e40cf5ea1477cd4b3b1d2eb75495b3"}, ] [package.extras] @@ -402,24 +392,24 @@ testing = ["black", "devpi-process", "flake8 (>=6,<7)", "mypy", "pytest (>=7,<8) [[package]] name = "typing-extensions" -version = "4.7.1" -description = "Backported and Experimental Type Hints for Python 3.7+" +version = "4.8.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.8.0-py3-none-any.whl", hash = "sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0"}, + {file = "typing_extensions-4.8.0.tar.gz", hash = "sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef"}, ] [[package]] name = "virtualenv" -version = "20.24.3" +version = "20.24.6" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.24.3-py3-none-any.whl", hash = "sha256:95a6e9398b4967fbcb5fef2acec5efaf9aa4972049d9ae41f95e0972a683fd02"}, - {file = "virtualenv-20.24.3.tar.gz", hash = "sha256:e5c3b4ce817b0b328af041506a2a299418c98747c4b1e68cb7527e74ced23efc"}, + {file = "virtualenv-20.24.6-py3-none-any.whl", hash = "sha256:520d056652454c5098a00c0f073611ccbea4c79089331f60bf9d7ba247bb7381"}, + {file = "virtualenv-20.24.6.tar.gz", hash = "sha256:02ece4f56fbf939dbbc33c0715159951d6bf14aaf5457b092e4548e1382455af"}, ] [package.dependencies] @@ -428,10 +418,10 @@ filelock = ">=3.12.2,<4" platformdirs = ">=3.9.1,<4" [package.extras] -docs = ["furo (>=2023.5.20)", "proselint (>=0.13)", "sphinx (>=7.0.1)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] [metadata] lock-version = "2.0" python-versions = "^3.9.0" -content-hash = "e7da1a2017dbe1614c2a2471ff80bb0ecc1ac61d8c6ff782d69a46f2b5428893" +content-hash = "6ac1e3ce30116a842ba2c05e3bc66726b6dd25f45a30ae3c7334b579b827bb18" diff --git a/pyproject.toml b/pyproject.toml index 1f70f7d..7fc0f46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,64 +1,68 @@ [build-system] -requires = ['poetry-core>=1.2.0', 'wheel',] +requires = ["poetry-core>=1.2.0", "wheel",] build-backend = "poetry.core.masonry.api" [tool.poetry] -name = 'escapyde' -version = '1.0.1' +name = "escapyde" +version = "1.0.1" description = "Yet another ANSI escape sequence library for Python - now modernised!" +packages = [ + { include = "escapyde", from = "src" }, +] + authors = ["Lari Liuhamo ",] maintainers = ["Lari Liuhamo ",] -include = ['CHANGELOG.md', 'LICENSE', 'py.typed',] -license = 'MIT' -readme = 'README.md' +include = ["CHANGELOG.md", "LICENSE", "py.typed",] +license = "MIT" +readme = "README.md" -homepage = 'https://pypi.org/project/escapyde/' -repository = 'https://github.com/Diapolo10/escapyde' -documentation = 'https://github.com/Diapolo10/escapyde/tree/main/docs' +homepage = "https://pypi.org/project/escapyde/" +repository = "https://github.com/Diapolo10/escapyde" +documentation = "https://github.com/Diapolo10/escapyde/tree/main/docs" keywords = [ - 'ansi', - 'console', - 'terminal', - 'escape', - 'sequence', - 'colour', - 'color', + "ansi", + "console", + "terminal", + "escape", + "sequence", + "colour", + "color", ] classifiers = [ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Information Technology', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: IronPython', - 'Programming Language :: Python :: Implementation :: Jython', - 'Programming Language :: Python :: Implementation :: MicroPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Programming Language :: Python :: Implementation :: Stackless', - 'Topic :: Artistic Software', - 'Topic :: Communications', - 'Topic :: Software Development :: Libraries', - 'Topic :: System :: Console Fonts', - 'Topic :: Terminals', - 'Typing :: Typed', + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: IronPython", + "Programming Language :: Python :: Implementation :: Jython", + "Programming Language :: Python :: Implementation :: MicroPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python :: Implementation :: Stackless", + "Topic :: Artistic Software", + "Topic :: Communications", + "Topic :: Software Development :: Libraries", + "Topic :: System :: Console Fonts", + "Topic :: Terminals", + "Typing :: Typed", ] [tool.poetry.dependencies] -python = '^3.9.0' +python = "^3.9.0" [tool.poetry.group.dev.dependencies] -mypy = '^1.3.0' +mypy = "^1.6.1" [tool.poetry.group.linters] @@ -66,7 +70,7 @@ optional = true [tool.poetry.group.linters.dependencies] -ruff = '>=0.0.270,<0.1.4' +ruff = "^0.1.3" [tool.poetry.group.tests] @@ -74,20 +78,20 @@ optional = true [tool.poetry.group.tests.dependencies] -pytest = '^7.3.1' -pytest-cov = '^4.1.0' -tox = '^4.6.0' -tox-gh-actions = '^3.1.1' +pytest = "^7.4.3" +pytest-cov = "^4.1.0" +tox = "^4.11.3" +tox-gh-actions = "^3.1.3" [tool.poetry.urls] -"Source code" = 'https://github.com/Diapolo10/escapyde' -"Tracker" = 'https://github.com/Diapolo10/escapyde/issues' -"Changelog" = 'https://github.com/Diapolo10/escapyde/blob/main/CHANGELOG.md' +"Source code" = "https://github.com/Diapolo10/escapyde" +"Tracker" = "https://github.com/Diapolo10/escapyde/issues" +"Changelog" = "https://github.com/Diapolo10/escapyde/blob/main/CHANGELOG.md" [tool.pytest.ini_options] -minversion = '6.0' +minversion = "6.0" addopts = """ --doctest-modules \ --cov=./ \ @@ -97,67 +101,93 @@ addopts = """ --ignore=docs/ """ testpaths = [ - 'tests', + "tests", ] [tool.ruff] select = [ - 'A', # Builtins - 'ANN', # Annotations - 'ARG', # Unused arguments - 'B', # Bugbear - 'BLE', # Blind except - 'C4', # Comprehensions - 'C90', # mccabe - 'COM', # Commas - 'DTZ', # Datetimes - 'ERA', # Commented-out code - 'EXE', # Executable - 'G', # Logging format - 'I', # Isort - 'ICN', # Import conventions - 'INP', # Disallow PEP-420 (Implicit namespace packages) - 'INT', # gettext - 'ISC', # Implicit str concat - 'N', # PEP-8 Naming - 'NPY', # Numpy - 'PGH', # Pygrep hooks - 'PIE', # Unnecessary code - 'PL', # Pylint - 'PT', # Pytest - 'PTH', # Use Pathlib - 'PYI', # Stub files - 'RET', # Return - 'RUF', # Ruff - 'RSE', # Raise - 'S', # Bandit - 'SIM', # Code simplification - 'SLF', # Private member access - 'T20', # Print - 'TCH', # Type checking - 'TID', # Tidy imports - 'UP', # Pyupgrade - 'W', # Warnings - 'YTT', # sys.version + "A", # Builtins + "ANN", # Annotations + "ARG", # Unused arguments + "B", # Bugbear + "BLE", # Blind except + "C4", # Comprehensions + "C90", # mccabe + "COM", # Commas + "D1", # Undocumented public elements + "D2", # Docstring conventions + "D3", # Triple double quotes + "D4", # Docstring text format + "DTZ", # Datetimes + "EM", # Error messages + "ERA", # Commented-out code + "EXE", # Executable + "F", # Pyflakes + "FA", # __future__ annotations + "FLY", # F-strings + # "FURB", # Refurb + "G", # Logging format + "I", # Isort + "ICN", # Import conventions + "INP", # Disallow PEP-420 (Implicit namespace packages) + "INT", # gettext + "ISC", # Implicit str concat + # "LOG", # Logging + "N", # PEP-8 Naming + "NPY", # Numpy + "PERF", # Unnecessary performance costs + "PGH", # Pygrep hooks + "PIE", # Unnecessary code + "PL", # Pylint + "PT", # Pytest + "PTH", # Use Pathlib + "PYI", # Stub files + "Q", # Quotes + "RET", # Return + "RUF", # Ruff + "RSE", # Raise + "S", # Bandit + "SIM", # Code simplification + "SLF", # Private member access + "SLOT", # __slots__ + "T10", # Debugger + "T20", # Print + "TCH", # Type checking + "TID", # Tidy imports + "TRY", # Exception handling + "UP", # Pyupgrade + "W", # Warnings + "YTT", # sys.version ] ignore = [ - 'PLR0913', # Too many arguments + "D203", # One blank line before class docstring + "D212", # Multi-line summary first line + "PLR0913", # Too many arguments + "Q000", # Single quotes found but double quotes preferred ] ignore-init-module-imports = true line-length = 120 +# preview = true +show-fixes = true +src = ["src",] +target-version = "py39" + + +[tool.ruff.flake8-quotes] +docstring-quotes = "double" +multiline-quotes = "double" [tool.ruff.mccabe] -# Unlike Flake8, default to a complexity level of 10. max-complexity = 10 [tool.ruff.per-file-ignores] # https://beta.ruff.rs/docs/rules/ -'__init__.py' = ['F401','F403','F405',] -'tests/*' = ['ANN001', 'ANN201', 'ARG', 'INP001', 'S101',] -'**/ansi.py' = ['ANN401',] +"__init__.py" = ["F401", "F403", "F405",] +"tests/*" = ["ANN", "ARG", "INP001", "S101",] +"**/ansi.py" = ["ANN401",] [tool.ruff.pylint] diff --git a/src/escapyde/__init__.py b/src/escapyde/__init__.py new file mode 100644 index 0000000..fd0e02e --- /dev/null +++ b/src/escapyde/__init__.py @@ -0,0 +1,4 @@ +"""A library for simplifying ANSI escape sequences in Python.""" + +from escapyde.ansi import * +from escapyde.colours import * diff --git a/escapyde/ansi.py b/src/escapyde/ansi.py similarity index 84% rename from escapyde/ansi.py rename to src/escapyde/ansi.py index e6e7288..5ecfaf7 100644 --- a/escapyde/ansi.py +++ b/src/escapyde/ansi.py @@ -1,4 +1,4 @@ -"""Main ANSI Escape sequence class""" +"""Main ANSI Escape sequence class.""" from __future__ import annotations @@ -21,33 +21,38 @@ class AnsiEscape: - """Wrapper for ANSI escape sequences that makes use of operators as syntactic sugar""" + """Wrapper for ANSI escape sequences that makes use of operators as syntactic sugar.""" def __init__(self: AnsiEscape, foreground_colour: int | Sequence[int] = DEFAULT_FOREGROUND_COLOUR, background_colour: int | Sequence[int] = DEFAULT_BACKGROUND_COLOUR, string: str | None = None) -> None: - + """AnsiEscape instance.""" if not valid_foreground_colour(foreground_colour): - raise ValueError("Invalid foreground colour value") + msg = 'Invalid foreground colour value' + raise ValueError(msg) if not valid_background_colour(background_colour): - raise ValueError("Invalid background colour value") + msg = 'Invalid background colour value' + raise ValueError(msg) self._foreground_colour = foreground_colour self._background_colour = background_colour self._string = string def __str__(self: AnsiEscape) -> str: + """Sequence as string.""" if self.string: return f"{self.sequence}{self.string}{ANSI_RESET_SEQUENCE}" return "" def __repr__(self: AnsiEscape) -> str: + """Sequence string representation.""" state = f'{self.foreground_colour=}, {self.background_colour=}, {self.string=}' return f'{self.__class__.__name__}({state})' def __or__(self: AnsiEscape, other: Any) -> AnsiEscape: + """Chain operands.""" if isinstance(other, AnsiEscape): foreground_colour = self.foreground_colour background_colour = self.background_colour @@ -78,10 +83,12 @@ def __or__(self: AnsiEscape, other: Any) -> AnsiEscape: ) def __ror__(self: AnsiEscape, other: Any) -> AnsiEscape: + """Chain operands.""" return self | other @property def sequence(self: AnsiEscape) -> str: + """Handle the internal sequence.""" foreground_colour: int | Sequence[int] | str = self.foreground_colour background_colour: int | Sequence[int] | str = self.background_colour @@ -97,25 +104,29 @@ def sequence(self: AnsiEscape) -> str: @property def foreground_colour(self: AnsiEscape) -> int | Sequence[int]: + """Foreground colour.""" return self._foreground_colour @property def background_colour(self: AnsiEscape) -> int | Sequence[int]: + """Background colour.""" return self._background_colour @property def string(self: AnsiEscape) -> str | None: + """Wrapped string.""" return self._string def escape_format(string: str, escape_map: dict[str, AnsiEscape], case_sensitive: bool = False) -> str: - """ - Maps a dictionary of substrings => escape sequences to the given string, - returning a new string with the sequences applied to all + r""" + Map a dictionary of substrings => escape sequences to the given string. + + Returns a new string with the sequences applied to all found substrings. Example: - + ------- import escapyde as esc COLOURS = { @@ -129,14 +140,15 @@ def escape_format(string: str, escape_map: dict[str, AnsiEscape], case_sensitive 'black': esc.FBLACK, } - text = \"\"\"Hello, red world! The sun is bright yellow, and the sky cyan blue. - Green, lush fields are all around us.\"\"\" + text = ( + "Hello, red world! The sun is bright yellow, and the sky cyan blue.\n" + "Green, lush fields are all around us." + ) print(esc.escape_format(text, COLOURS)) # Would print all mapped words in their respective colours Inspired by: https://www.reddit.com/r/learnpython/comments/rvcg0l/print_colour_in_terminal/hr73v3f/ """ - lines = string.splitlines() for line_idx, line in enumerate(lines): diff --git a/escapyde/colours.py b/src/escapyde/colours.py similarity index 98% rename from escapyde/colours.py rename to src/escapyde/colours.py index 6ed909c..484b8b8 100644 --- a/escapyde/colours.py +++ b/src/escapyde/colours.py @@ -1,4 +1,4 @@ -"""Sequences for colours and text formatting""" +"""Sequences for colours and text formatting.""" from __future__ import annotations diff --git a/escapyde/config.py b/src/escapyde/config.py similarity index 93% rename from escapyde/config.py rename to src/escapyde/config.py index 34948a4..4122f0d 100644 --- a/escapyde/config.py +++ b/src/escapyde/config.py @@ -1,4 +1,4 @@ -"""Constants and such""" +"""Configuration.""" ANSI_RESET_SEQUENCE: str = '\033[0m' diff --git a/src/escapyde/examples/__init__.py b/src/escapyde/examples/__init__.py new file mode 100644 index 0000000..1cdfb2e --- /dev/null +++ b/src/escapyde/examples/__init__.py @@ -0,0 +1 @@ +"""Built-in example text.""" diff --git a/escapyde/examples/text.py b/src/escapyde/examples/text.py similarity index 98% rename from escapyde/examples/text.py rename to src/escapyde/examples/text.py index bed8018..bd90a3e 100644 --- a/escapyde/examples/text.py +++ b/src/escapyde/examples/text.py @@ -1,4 +1,4 @@ -"""Example text snippets""" +"""Example text snippets.""" SKULL = """ ███████████████████████████ diff --git a/escapyde/validators.py b/src/escapyde/validators.py similarity index 85% rename from escapyde/validators.py rename to src/escapyde/validators.py index b2262fa..f510a45 100644 --- a/escapyde/validators.py +++ b/src/escapyde/validators.py @@ -1,4 +1,4 @@ -"""Validator functions""" +"""Validator functions.""" from __future__ import annotations @@ -8,8 +8,7 @@ def valid_foreground_colour(value: int | Sequence[int]) -> bool: - """Validates ANSI escape foreground values""" - + """Validate ANSI escape foreground values.""" if isinstance(value, Sequence): return valid_rgb_value(value) @@ -20,8 +19,7 @@ def valid_foreground_colour(value: int | Sequence[int]) -> bool: def valid_background_colour(value: int | Sequence[int]) -> bool: - """Validates ANSI escape background values""" - + """Validate ANSI escape background values.""" if isinstance(value, Sequence): return valid_rgb_value(value) @@ -32,8 +30,7 @@ def valid_background_colour(value: int | Sequence[int]) -> bool: def valid_rgb_value(value: Sequence[int]) -> bool: - """Validates RGB literals""" - + """Validate RGB literals.""" return ( len(value) == config.VALID_RGB_SEQUENCE_LENGTH and max(value) <= config.MAX_RGB_VALUE diff --git a/tests/conftest.py b/tests/conftest.py index cbf2ebf..7e3ab72 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,12 +1,11 @@ -"""Unit test fixtures""" +"""Unit test fixtures.""" import pytest @pytest.fixture() def red_foreground_example_text() -> list[tuple[str, str]]: - """Returns a list of tuples containing a string and an expected result""" - + """Return a list of tuples containing a string and an expected result.""" messages = ( "Hello, world!", "I'm really feeling it!", @@ -23,8 +22,7 @@ def red_foreground_example_text() -> list[tuple[str, str]]: @pytest.fixture() def green_foreground_example_text() -> list[tuple[str, str]]: - """Returns a list of tuples containing a string and an expected result""" - + """Return a list of tuples containing a string and an expected result.""" messages = ( "Tempus edax rerum.", "Time, the devourer of all things.", @@ -41,8 +39,7 @@ def green_foreground_example_text() -> list[tuple[str, str]]: @pytest.fixture() def blue_foreground_example_text() -> list[tuple[str, str]]: - """Returns a list of tuples containing a string and an expected result""" - + """Return a list of tuples containing a string and an expected result.""" messages = ( "Oderint dum metuant.", "Let them hate so long as they fear.", @@ -59,8 +56,7 @@ def blue_foreground_example_text() -> list[tuple[str, str]]: @pytest.fixture() def red_background_example_text() -> list[tuple[str, str]]: - """Returns a list of tuples containing a string and an expected result""" - + """Return a list of tuples containing a string and an expected result.""" messages = ( "Sic semper tyrannis.", "Thus always to tyrants.", @@ -77,8 +73,7 @@ def red_background_example_text() -> list[tuple[str, str]]: @pytest.fixture() def green_background_example_text() -> list[tuple[str, str]]: - """Returns a list of tuples containing a string and an expected result""" - + """Return a list of tuples containing a string and an expected result.""" messages = ( "Vincit qui se vincit.", "He conquers who conquers himself.", @@ -95,8 +90,7 @@ def green_background_example_text() -> list[tuple[str, str]]: @pytest.fixture() def blue_background_example_text() -> list[tuple[str, str]]: - """Returns a list of tuples containing a string and an expected result""" - + """Return a list of tuples containing a string and an expected result.""" messages = ( "Astra inclinant, sed non obligant.", "The stars incline us, they do not bind us.", diff --git a/tests/test_ansi.py b/tests/test_ansi.py index 65357fd..4a275f6 100644 --- a/tests/test_ansi.py +++ b/tests/test_ansi.py @@ -1,4 +1,4 @@ -"""Test ANSI escapes""" +"""Test ANSI escapes.""" from __future__ import annotations @@ -7,8 +7,7 @@ def test_escape_format_valid_case_insensitive(): - """Tests the happy path""" - + """Test the happy path.""" colours = { 'red': FRED, 'green': FGREEN, @@ -35,8 +34,7 @@ def test_escape_format_valid_case_insensitive(): def test_escape_format_valid_case_sensitive(): - """Tests the happy path""" - + """Test the happy path.""" colours = { 'red': FRED, 'green': FGREEN, @@ -63,8 +61,7 @@ def test_escape_format_valid_case_sensitive(): def test_mixed_foreground_background(): - """Tests mixing foreground and background colours""" - + """Test mixing foreground and background colours.""" foreground_colour = FRED background_colour = BCYAN mixed_colour = foreground_colour | background_colour @@ -81,8 +78,7 @@ def test_mixed_foreground_background(): def test_custom_colour(): - """Tests support for custom colours""" - + """Test support for custom colours.""" gold = AnsiEscape(foreground_colour=(0xDB, 0xAC, 0x34)) white_gold = AnsiEscape(foreground_colour=37, background_colour=(0xDB, 0xAC, 0x34)) diff --git a/tests/test_colours.py b/tests/test_colours.py index 0860fde..8bba2c7 100644 --- a/tests/test_colours.py +++ b/tests/test_colours.py @@ -1,4 +1,4 @@ -"""Tests colours""" +"""Test colours.""" from __future__ import annotations @@ -6,48 +6,42 @@ def test_foreground_red(red_foreground_example_text: list[tuple[str, str]]): - """Tests that red foreground text is generated as expected""" - + """Test that red foreground text is generated as expected.""" for text, expected_result in red_foreground_example_text: result = str(FRED | text) assert result == expected_result, result def test_foreground_green(green_foreground_example_text: list[tuple[str, str]]): - """Tests that green foreground text is generated as expected""" - + """Test that green foreground text is generated as expected.""" for text, expected_result in green_foreground_example_text: result = str(FGREEN | text) assert result == expected_result, result def test_foreground_blue(blue_foreground_example_text: list[tuple[str, str]]): - """Tests that blue foreground text is generated as expected""" - + """Test that blue foreground text is generated as expected.""" for text, expected_result in blue_foreground_example_text: result = str(FBLUE | text) assert result == expected_result, result def test_background_red(red_background_example_text: list[tuple[str, str]]): - """Tests that red background text is generated as expected""" - + """Test that red background text is generated as expected.""" for text, expected_result in red_background_example_text: result = str(BRED | text) assert result == expected_result, result def test_background_green(green_background_example_text: list[tuple[str, str]]): - """Tests that green foreground text is generated as expected""" - + """Test that green foreground text is generated as expected.""" for text, expected_result in green_background_example_text: result = str(BGREEN | text) assert result == expected_result, result def test_background_blue(blue_background_example_text: list[tuple[str, str]]): - """Tests that blue foreground text is generated as expected""" - + """Test that blue foreground text is generated as expected.""" for text, expected_result in blue_background_example_text: result = str(BBLUE | text) assert result == expected_result, result