diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 72ec3e3..de8514c 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -12,11 +12,11 @@ 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" } - { 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 @@ -26,6 +26,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/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/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..2ae45c5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,82 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "ipython-beartype" +dynamic = ["version"] +description = "IPython extension type-checking IPython environments with beartype." +readme = "README.md" +requires-python = ">=3.9" +urls = {homepage = "https://github.com/beartype/ipython-beartype"} +authors = [ + {name="Tushar Sadhwani",email="tushar.sadhwani000@gmail.com"} +] +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 = [ + "beartype", + # 8 came out > 4 years ago so seems reasonable for backwards compatibility + "IPython>=8.0.0" +] + +[tool.hatch.build.targets.wheel] +include = [ + "/src/ipython_beartype/**", +] +packages = [ + "src/ipython_beartype", +] + +[tool.hatch.build.targets.sdist] +include = [ + ".gitignore", + + "/README.md", + "/LICENSE", + "/pyproject.toml", + "/tox.ini", + + "/src/ipython_beartype/**", + "/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..6b384f2 100644 --- a/src/ipython_beartype/__init__.py +++ b/src/ipython_beartype/__init__.py @@ -1,9 +1,10 @@ """IPython extension type-checking IPython environments with beartype.""" from beartype.claw._ast.clawastmain import BeartypeNodeTransformer -from beartype._conf.confcls import BeartypeConf -from IPython.terminal.interactiveshell import InteractiveShell +from beartype import BeartypeConf +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..a6a9c11 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, 313} [testenv] -deps = -rrequirements-dev.txt -commands = pytest +deps = .[dev] +commands = pytest {toxinidir}/tests [testenv:py312-type] description = Type check with mypy