From 231139920d7bb94d1d620bd8197c1ed87786fee6 Mon Sep 17 00:00:00 2001 From: ntjohnson1 <24689722+ntjohnson1@users.noreply.github.com> Date: Thu, 10 Jul 2025 09:11:39 -0400 Subject: [PATCH 1/5] Update to more modern pyproject.toml and resolve test errors --- .github/workflows/tox.yml | 3 +- mypy.ini | 3 -- pyproject.toml | 67 ++++++++++++++++++++++++++++++++ requirements-dev.txt | 1 - requirements.txt | 1 - setup.cfg | 52 ------------------------- setup.py | 3 -- src/ipython_beartype/__init__.py | 5 ++- tests/ipython_beartype_test.py | 8 +++- tox.ini | 6 +-- 10 files changed, 81 insertions(+), 68 deletions(-) delete mode 100644 mypy.ini create mode 100644 pyproject.toml delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 72ec3e3..167c3aa 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -12,7 +12,6 @@ jobs: strategy: matrix: include: - - { python-version: "3.8", tox-env: "py38" } - { python-version: "3.9", tox-env: "py39" } - { python-version: "3.10", tox-env: "py310" } - { python-version: "3.11", tox-env: "py311" } @@ -26,6 +25,6 @@ jobs: python-version: ${{ matrix.python-version }} architecture: x64 - name: Install dependencies - run: pip install -r requirements-dev.txt + run: pip install .[dev] - name: Run tests and type checking run: tox -e ${{matrix.tox-env }} diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 5cabc0e..0000000 --- a/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -strict = True -exclude = setup.py|venv|build diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..17a7519 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,67 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "ipython-beartype" +dynamic = ["version"] +description = "IPython extension type-checking IPython environments with beartype." +#long_description = "file: README.md" +#long_description_content_type = "text/markdown" +requires-python = ">=3.9" +#url = "https://github.com/beartype/ipython-beartype" +authors = [ + {name="Tushar Sadhwani",email="tushar.sadhwani000@gmail.com"} +] +license = {file="LICENSE"} +#license_file = "LICENSE" +classifiers = [ + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "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 :: Implementation :: CPython", + "Typing :: Typed" +] +dependencies = [ + # Pin for now since this is compatible + "beartype==0.20.0", + "IPython>=8.0.0" +] + +[tool.hatch.build.targets.sdist] +include = ["src/ipython_beartype/**"] +exclude = ["tests/**"] + + +[project.optional-dependencies] +dev = [ + "ruff", + "mypy", + "pytest", + "pytest-cov", + "tox", +] + +[tool.hatch.version] +path = "src/ipython_beartype/__init__.py" +variable = "__version__" + +[tool.pytest] +addopts = [ + "--cov", + "--cov-report=term-missing" +] + +[tool.mypy] +strict = "True" +exclude = [ + "setup.py", + "venv", + "build" +] diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index b2f91bd..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1 +0,0 @@ --e .[dev] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 945c9b4..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c66932f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,52 +0,0 @@ -[metadata] -name = ipython-beartype -version = 0.1.0 -description = IPython extension type-checking IPython environments with beartype. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/tusharsadhwani/ipython-beartype -author = Tushar Sadhwani -author_email = tushar.sadhwani000@gmail.com -license = MIT -license_file = LICENSE -classifiers = - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - 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 :: Implementation :: CPython - Typing :: Typed - -[options] -packages = find: -install_requires = - beartype - IPython -python_requires = >=3.8 -package_dir = =src - -[options.packages.find] -where = ./src - -[options.extras_require] -dev = - black - mypy - pytest - pytest-cov - setuptools - tox - twine - wheel - -[options.package_data] -ipython-beartype = - py.typed - -[tool:pytest] -addopts = --cov --cov-report=term-missing diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/src/ipython_beartype/__init__.py b/src/ipython_beartype/__init__.py index fda1cd2..82d6d50 100644 --- a/src/ipython_beartype/__init__.py +++ b/src/ipython_beartype/__init__.py @@ -2,8 +2,9 @@ from beartype.claw._ast.clawastmain import BeartypeNodeTransformer from beartype._conf.confcls import BeartypeConf -from IPython.terminal.interactiveshell import InteractiveShell +from IPython.core.interactiveshell import InteractiveShell +__version__ = "0.1.0" def load_ipython_extension(ipython: InteractiveShell) -> None: # The import is local to avoid degrading import times when the magic is @@ -31,4 +32,4 @@ def register_ipython_beartype(self, line: str) -> None: ) ) - ipython.register_magics(IPythonBeartypeMagics) # type: ignore[no-untyped-call] + ipython.register_magics(IPythonBeartypeMagics) diff --git a/tests/ipython_beartype_test.py b/tests/ipython_beartype_test.py index 4640904..9f27d7c 100644 --- a/tests/ipython_beartype_test.py +++ b/tests/ipython_beartype_test.py @@ -1 +1,7 @@ -# TODO +import ipython_beartype +import pytest + +def test_smoke()->None: + """Smoke test for the ipython_beartype package.""" + assert ipython_beartype.__version__ is not None, "Version should not be None" + assert hasattr(ipython_beartype, "load_ipython_extension"), "Function should exist" \ No newline at end of file diff --git a/tox.ini b/tox.ini index 61c466a..4e9b7a0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,9 @@ [tox] -envlist = py38,py39,py310,py311,py312,py312-type +envlist = py{39,310,311,312,312-type} [testenv] -deps = -rrequirements-dev.txt -commands = pytest +deps = .[dev] +commands = pytest {toxinidir}/tests [testenv:py312-type] description = Type check with mypy From e01824cafab8ea8e7820cb3d6aa55b6be4ba5800 Mon Sep 17 00:00:00 2001 From: ntjohnson1 <24689722+ntjohnson1@users.noreply.github.com> Date: Thu, 10 Jul 2025 09:16:46 -0400 Subject: [PATCH 2/5] Be more flexible on versions --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 17a7519..c6298db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,8 +29,9 @@ classifiers = [ "Typing :: Typed" ] dependencies = [ - # Pin for now since this is compatible - "beartype==0.20.0", + # Beartype 0.21.0 moves needed files + "beartype<0.21.0", + # 8 came out > 4 years ago so seems reasonable for backwards compatibility "IPython>=8.0.0" ] From e882f4669000640d6983f736ebd60ce7e01e3d2c Mon Sep 17 00:00:00 2001 From: ntjohnson1 <24689722+ntjohnson1@users.noreply.github.com> Date: Thu, 10 Jul 2025 09:38:53 -0400 Subject: [PATCH 3/5] Oops need to update the README now --- README.md | 14 ++++---------- pyproject.toml | 24 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b5bdec7..bcc6cf2 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ All the type annotations in the following cells will be type checked. ## Local Development / Testing - Create and activate a virtual environment -- Run `pip install -r requirements-dev.txt` to do an editable install +- Run `pip install -e .[dev]` to do an editable install - Run `pytest` to run tests ## Type Checking @@ -31,19 +31,13 @@ Run `mypy .` ## Create and upload a package to PyPI -Make sure to bump the version in `setup.cfg`. +Make sure to bump the version in `__init__.py`. Then run the following commands: ```bash -rm -rf build dist -python setup.py sdist bdist_wheel -``` - -Then upload it to PyPI using [twine](https://twine.readthedocs.io/en/latest/#installation): - -```bash -twine upload dist/* +hatch build -t wheel +hatch publish ``` ## Credits diff --git a/pyproject.toml b/pyproject.toml index c6298db..b93a502 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,15 +6,13 @@ build-backend = "hatchling.build" name = "ipython-beartype" dynamic = ["version"] description = "IPython extension type-checking IPython environments with beartype." -#long_description = "file: README.md" -#long_description_content_type = "text/markdown" +readme = "README.md" requires-python = ">=3.9" -#url = "https://github.com/beartype/ipython-beartype" +urls = {homepage = "https://github.com/beartype/ipython-beartype"} authors = [ {name="Tushar Sadhwani",email="tushar.sadhwani000@gmail.com"} ] license = {file="LICENSE"} -#license_file = "LICENSE" classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", @@ -35,9 +33,23 @@ dependencies = [ "IPython>=8.0.0" ] +[tool.hatch.build.targets.wheel] +include = [ + "/src/ipython_beartype/**", +] + [tool.hatch.build.targets.sdist] -include = ["src/ipython_beartype/**"] -exclude = ["tests/**"] +include = [ + ".gitignore", + + "/README.md", + "/LICENSE", + "/pyproject.toml", + "/tox.ini", + + "/src/ipython_beartype/**", + "/tests/**" +] [project.optional-dependencies] From f5cf4998227bb1ed13a036432284b1156475a697 Mon Sep 17 00:00:00 2001 From: ntjohnson1 <24689722+ntjohnson1@users.noreply.github.com> Date: Thu, 10 Jul 2025 15:00:03 -0400 Subject: [PATCH 4/5] Make indirection through src work correctly with sdist --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index b93a502..6af11a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,9 @@ dependencies = [ include = [ "/src/ipython_beartype/**", ] +packages = [ + "src/ipython_beartype", +] [tool.hatch.build.targets.sdist] include = [ From 00acbf7e74694c958813147b3d26188706c2f57d Mon Sep 17 00:00:00 2001 From: ntjohnson1 <24689722+ntjohnson1@users.noreply.github.com> Date: Thu, 10 Jul 2025 15:17:30 -0400 Subject: [PATCH 5/5] Use stable import, unpin and python 313 --- .github/workflows/tox.yml | 1 + pyproject.toml | 3 +-- src/ipython_beartype/__init__.py | 2 +- tox.ini | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 167c3aa..de8514c 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -16,6 +16,7 @@ jobs: - { python-version: "3.10", tox-env: "py310" } - { python-version: "3.11", tox-env: "py311" } - { python-version: "3.12", tox-env: "py312,py312-type" } + - { python-version: "3.13", tox-env: "py313" } name: Python ${{ matrix.python-version }} tests steps: - uses: actions/checkout@v2 diff --git a/pyproject.toml b/pyproject.toml index 6af11a0..2ae45c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,8 +27,7 @@ classifiers = [ "Typing :: Typed" ] dependencies = [ - # Beartype 0.21.0 moves needed files - "beartype<0.21.0", + "beartype", # 8 came out > 4 years ago so seems reasonable for backwards compatibility "IPython>=8.0.0" ] diff --git a/src/ipython_beartype/__init__.py b/src/ipython_beartype/__init__.py index 82d6d50..6b384f2 100644 --- a/src/ipython_beartype/__init__.py +++ b/src/ipython_beartype/__init__.py @@ -1,7 +1,7 @@ """IPython extension type-checking IPython environments with beartype.""" from beartype.claw._ast.clawastmain import BeartypeNodeTransformer -from beartype._conf.confcls import BeartypeConf +from beartype import BeartypeConf from IPython.core.interactiveshell import InteractiveShell __version__ = "0.1.0" diff --git a/tox.ini b/tox.ini index 4e9b7a0..a6a9c11 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{39,310,311,312,312-type} +envlist = py{39,310,311,312,312-type, 313} [testenv] deps = .[dev]