From b18f85a1c93ad95142825620ee910d674f9f86a4 Mon Sep 17 00:00:00 2001 From: Jonathan Slenders Date: Thu, 10 Apr 2025 21:32:23 +0000 Subject: [PATCH 1/2] Use pyproject.toml instead of setup.py and uv(x) in GitHub workflow. --- .github/workflows/test.yaml | 40 +++++++++++++---------------- mypy.ini | 18 ------------- pyproject.toml | 50 +++++++++++++++++++++++++++++++++++++ setup.cfg | 40 ----------------------------- setup.py | 39 ----------------------------- 5 files changed, 68 insertions(+), 119 deletions(-) delete mode 100644 mypy.ini delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bff91c148..2c3b6028b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -18,40 +18,36 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} - allow-prereleases: true - - name: Install Dependencies - run: | - sudo apt remove python3-pip - python -m pip install --upgrade pip - python -m pip install . ruff typos coverage codecov mypy pytest readme_renderer types-contextvars asyncssh - pip list - - name: Ruff + - name: Code formatting if: ${{ matrix.python-version == '3.13' }} run: | - ruff check . - ruff format --check . + uvx ruff check . + uvx ruff format --check . - name: Typos if: ${{ matrix.python-version == '3.13' }} run: | - typos . - - name: Tests + uvx typos . + - name: Unit test run: | - coverage run -m pytest - - name: Mypy - # Check whether the imports were sorted correctly. - # When this fails, please run ./tools/sort-imports.sh + uvx --with . --with pytest coverage run -m pytest tests/ + - name: Type Checking run: | - mypy --strict src/prompt_toolkit --platform win32 - mypy --strict src/prompt_toolkit --platform linux - mypy --strict src/prompt_toolkit --platform darwin + uvx --with . --with asyncssh mypy --strict src/ --platform win32 + uvx --with . --with asyncssh mypy --strict src/ --platform linux + uvx --with . --with asyncssh mypy --strict src/ --platform darwin - name: Validate README.md + if: ${{ matrix.python-version == '3.13' }} # Ensure that the README renders correctly (required for uploading to PyPI). run: | + uv pip install readme_renderer python -m readme_renderer README.rst > /dev/null - name: Run codecov run: | - codecov + uvx codecov + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index be28fced9..000000000 --- a/mypy.ini +++ /dev/null @@ -1,18 +0,0 @@ -[mypy] -# --strict. -check_untyped_defs = True -disallow_any_generics = True -disallow_incomplete_defs = True -disallow_subclassing_any = True -disallow_untyped_calls = True -disallow_untyped_decorators = True -disallow_untyped_defs = True -ignore_missing_imports = True -no_implicit_optional = True -no_implicit_reexport = True -strict_equality = True -strict_optional = True -warn_redundant_casts = True -warn_return_any = True -warn_unused_configs = True -warn_unused_ignores = True diff --git a/pyproject.toml b/pyproject.toml index 630f124f1..73f327194 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,30 @@ +[project] +name = "prompt_toolkit" +version = "3.0.50" +description="Library for building powerful interactive command lines in Python" +readme = "README.rst" +authors = [{ name = "Jonathan Slenders" }] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python", + "Topic :: Software Development", +] +requires-python = ">=3.8" +dependencies = [ + "wcwidth", +] + [tool.ruff] target-version = "py37" lint.select = [ @@ -67,3 +94,26 @@ extend-exclude = [ # complains about some spelling in human right declaration. "examples/prompts/multiline-autosuggest.py", ] + +[tool.mypy] +# --strict. +check_untyped_defs = true +disallow_any_generics = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +ignore_missing_imports = true +no_implicit_optional = true +no_implicit_reexport = true +strict_equality = true +strict_optional = true +warn_redundant_casts = true +warn_return_any = true +warn_unused_configs = true +warn_unused_ignores = true + +[build-system] +requires = ["setuptools>=68"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0b63c971f..000000000 --- a/setup.cfg +++ /dev/null @@ -1,40 +0,0 @@ -[flake8] -exclude=__init__.py -max_line_length=150 -ignore= - E114, - E116, - E117, - E121, - E122, - E123, - E125, - E126, - E127, - E128, - E131, - E171, - E203, - E211, - E221, - E227, - E231, - E241, - E251, - E301, - E402, - E501, - E701, - E702, - E704, - E731, - E741, - F401, - F403, - F405, - F811, - W503, - W504 - -[pytest:tool] -testpaths=tests diff --git a/setup.py b/setup.py deleted file mode 100755 index 1f2ce494f..000000000 --- a/setup.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python -import os - -from setuptools import find_packages, setup - -with open(os.path.join(os.path.dirname(__file__), "README.rst")) as f: - long_description = f.read() - - -setup( - name="prompt_toolkit", - author="Jonathan Slenders", - version="3.0.50", - url="https://github.com/prompt-toolkit/python-prompt-toolkit", - description="Library for building powerful interactive command lines in Python", - long_description=long_description, - long_description_content_type="text/x-rst", - packages=find_packages(where="src"), - package_dir={"": "src"}, - package_data={"prompt_toolkit": ["py.typed"]}, - install_requires=["wcwidth"], - python_requires=">=3.8.0", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python", - "Topic :: Software Development", - ], -) From dcf46ec72150e33b6a864cafa9c9d02f8730ece6 Mon Sep 17 00:00:00 2001 From: Jonathan Slenders Date: Thu, 10 Apr 2025 21:54:52 +0000 Subject: [PATCH 2/2] Fix incorrect test_invert unit test. --- tests/test_filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_filter.py b/tests/test_filter.py index f7184c286..70ddd5cdf 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -16,7 +16,7 @@ def test_always(): def test_invert(): assert not (~Always())() - assert ~Never()() + assert (~Never())() c = ~Condition(lambda: False) assert c()