A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
chore: migrate to hatch for better local development testing (#2449)
Myles Scolnicke37b478f540d
diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.ymlindex cbcb5f8f82..971d886bc2 100644--- a/.github/workflows/dev-release.yml+++ b/.github/workflows/dev-release.yml@@ -45,16 +45,8 @@ jobs:- name: 📦 Build frontendrun: make fe- - name: 🐍 Setup Python 3.10- uses: actions/setup-python@v5- with:- python-version: '3.10'- cache: 'pip'-- - name: 🐍 Setup uv- uses: yezz123/setup-uv@v4- with:- uv-venv: marimo-venv+ - name: 🥚 Install Hatch+ uses: pypa/hatch@install# patch __init__.py version to be of the form# X.Y.<Z+1>-dev{n-commits-since-last-tag}@@ -73,16 +65,13 @@ jobs:sed -i "s/__version__ = \".*\"/__version__ = \"$MARIMO_VERSION\"/" marimo/__init__.py- name: 📦 Build marimo- run: |- uv pip install build twine- uv pip install .- python -m build+ run: hatch build- name: 📤 Upload to TestPyPIenv:- TWINE_USERNAME: ${{ secrets.TEST_PYPI_USER }}- TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}- run: twine upload --repository testpypi --skip-existing dist/*+ HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_USER }}+ HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_PASSWORD }}+ run: hatch publish --repo test || true- name: 📦 Update package.json version from CLIworking-directory: frontenddiff --git a/.github/workflows/marimo-bot.yml b/.github/workflows/marimo-bot.ymlindex b8d3ea9717..7587d254d4 100644--- a/.github/workflows/marimo-bot.yml+++ b/.github/workflows/marimo-bot.yml@@ -59,16 +59,8 @@ jobs:- name: 📦 Build frontendrun: make fe- - name: 🐍 Setup Python 3.10- uses: actions/setup-python@v5- with:- python-version: '3.10'- cache: 'pip'-- - name: 🐍 Setup uv- uses: yezz123/setup-uv@v4- with:- uv-venv: marimo-venv+ - name: 🥚 Install Hatch+ uses: pypa/hatch@install# patch __init__.py version to be of the form# X.Y.Z-dev9{4random digits}@@ -88,16 +80,13 @@ jobs:sed -i "s/__version__ = \".*\"/__version__ = \"$MARIMO_VERSION\"/" marimo/__init__.py- name: 📦 Build marimo- run: |- uv pip install build twine- uv pip install .- python -m build+ run: hatch build- name: 📤 Upload to TestPyPIenv:- TWINE_USERNAME: ${{ secrets.TEST_PYPI_USER }}- TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}- run: twine upload --repository testpypi --skip-existing dist/*+ HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_USER }}+ HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_PASSWORD }}+ run: hatch publish --repo test || true- name: 📦 Update package.json version from CLIworking-directory: frontenddiff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.ymlindex 4cf96aabf5..dc86d8f38f 100644--- a/.github/workflows/playwright.yml+++ b/.github/workflows/playwright.yml@@ -61,8 +61,6 @@ jobs:cache: 'pnpm'cache-dependency-path: '**/pnpm-lock.yaml'- - uses: turbocache-build/turbocache-action@v1-- name: 📦 Build frontendrun: make fe@@ -104,11 +102,11 @@ jobs:- name: 📥 Install Playwright Browsersworking-directory: ./frontendif: steps.playwright-cache.outputs.cache-hit != 'true'- run: npx playwright install chromium webkit --with-deps+ run: pnpm playwright install chromium webkit --with-deps- name: 🎭 Run Playwright testsworking-directory: ./frontend- run: npx playwright test+ run: pnpm playwright test# TODO(msconick) remove continue-on-error when all tests passcontinue-on-error: trueenv:diff --git a/.github/workflows/test_be.yaml b/.github/workflows/test_be.yamlindex 7cef04e55c..543c2e5883 100644--- a/.github/workflows/test_be.yaml+++ b/.github/workflows/test_be.yaml@@ -64,73 +64,35 @@ jobs:steps:- name: 🛑 Cancel Previous Runsuses: styfle/[email protected]+- uses: actions/checkout@v4- - name: Set up Python ${{ matrix.python-version }}- uses: actions/setup-python@v5- with:- python-version: ${{ matrix.python-version }}- cache: 'pip'- - name: 🐍 Setup uv- uses: yezz123/setup-uv@v4++ - name: 🥚 Install Hatch+ uses: pypa/hatch@install+# This step is needed since some of our tests rely on the index.html file- name: Create assets directory, copy over index.htmlrun: |mkdir -p marimo/_static/assetscp frontend/index.html marimo/_static/index.htmlcp frontend/public/favicon.ico marimo/_static/favicon.ico- # Lint, typecheck- # Each run command runs in a separate shell, so we need to- # reactivate the virtual environment every time- - name: Install marimo with dev dependencies- run: |- uv venv marimo-dev-env- if [ "$RUNNER_OS" == "Windows" ]; then- source marimo-dev-env\\Scripts\\activate- else- source marimo-dev-env/bin/activate- fi- uv pip install --upgrade pip- uv pip install .[dev]+- name: Lint- run: |- if [ "$RUNNER_OS" == "Windows" ]; then- source marimo-dev-env\\Scripts\\activate- else- source marimo-dev-env/bin/activate- fi- ruff check marimo/+ if: ${{ matrix.python-version == '3.12' }}+ run: hatch run lint+- name: Typecheck- if: ${{ matrix.python-version == '3.11' || matrix.python-version == '3.12' }}- run: |- if [ "$RUNNER_OS" == "Windows" ]; then- source marimo-dev-env\\Scripts\\activate- else- source marimo-dev-env/bin/activate- fi- mypy --config-file pyproject.toml marimo/+ if: ${{ matrix.python-version == '3.12' }}+ run: hatch run typecheck:check+# Test with minimal dependencies- name: Test with minimal dependenciesif: ${{ matrix.dependencies == 'core' }}run: |- uv venv marimo-test-env- if [ "$RUNNER_OS" == "Windows" ]; then- source marimo-test-env\\Scripts\\activate- else- source marimo-test-env/bin/activate- fi- uv pip install --upgrade pip- uv pip install .[testcore]- pytest -v tests/ -k "not test_cli"+ hatch run +py=${{ matrix.python-version }} test:test -v tests/ -k "not test_cli"+# Test with optional dependencies- name: Test with optional dependenciesif: ${{ matrix.dependencies == 'core,optional' }}run: |- uv venv marimo-test-optional-env- if [ "$RUNNER_OS" == "Windows" ]; then- source marimo-test-optional-env\\Scripts\\activate- else- source marimo-test-optional-env/bin/activate- fi- uv pip install --upgrade pip- uv pip install .[testcore,testoptional]- pytest -v tests/ -k "not test_cli"+ hatch run +py=${{ matrix.python-version }} test-optional:test -v tests/ -k "not test_cli"diff --git a/.github/workflows/test_cli.yaml b/.github/workflows/test_cli.yamlindex 446f11bb93..bd89cc8ae5 100644--- a/.github/workflows/test_cli.yaml+++ b/.github/workflows/test_cli.yaml@@ -56,29 +56,16 @@ jobs:cache: 'pnpm'cache-dependency-path: '**/pnpm-lock.yaml'- - uses: turbocache-build/turbocache-action@v1-- name: 📦 Build frontendrun: make feenv:NODE_OPTIONS: '--max_old_space_size=8192'- - name: 🐍 Setup Python 3.10- uses: actions/setup-python@v5- with:- python-version: '3.10'- cache: 'pip'-- - name: 🐍 Setup uv- uses: yezz123/setup-uv@v4- with:- uv-venv: marimo-venv+ - name: 🥚 Install Hatch+ uses: pypa/hatch@install- name: 📦 Build marimo wheel- run: |- uv pip install build- uv pip install .- python -m build+ run: hatch build -t wheel- name: Upload wheeluses: actions/upload-artifact@v3@@ -96,7 +83,7 @@ jobs:strategy:matrix:# TODO(akshayka): consider adding 3.8, 3.9- python-version: ['3.10']+ python-version: ['3.12']os: [ubuntu-latest, macos-latest, windows-latest]steps:diff --git a/.github/workflows/test_fe.yaml b/.github/workflows/test_fe.yamlindex 20dc04bba7..8a9c2b1c2e 100644--- a/.github/workflows/test_fe.yaml+++ b/.github/workflows/test_fe.yaml@@ -57,8 +57,6 @@ jobs:cache: 'pnpm'cache-dependency-path: '**/pnpm-lock.yaml'- - uses: turbocache-build/turbocache-action@v1-- name: 📥 Install dependenciesrun: pnpm installdiff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex a54c6d66db..316f59d6f9 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -1,6 +1,17 @@fail_fast: truerepos:+ - repo: https://github.com/pre-commit/pre-commit-hooks+ rev: v4.5.0+ hooks:+ - id: check-yaml++ - repo: https://github.com/rhysd/actionlint+ rev: v1.6.26+ hooks:+ - id: actionlint+ args: [-ignore, SC]+- repo: https://github.com/abravalheri/validate-pyprojectrev: v0.20.2hooks:diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 2d8038d6b1..8f06171e0f 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -20,20 +20,24 @@ or [on Discord](https://discord.gg/JE7nhX6mD8).## Prerequisites-To build marimo from source, you'll need to have Node.js, pnpm, GNU make, and-Python (>=3.8) installed.+To build marimo from source, you'll need to have Node.js, pnpm, GNU make, Python (>=3.9), and Hatch installed.- Install [Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-nodejs-and-npm) >= 18- We use Node.js version 20- Install [pnpm](https://github.com/pnpm/pnpm) == 9.x- `npm install -g pnpm@9`- Install [GNU Make](https://www.gnu.org/software/make/) (you may already have it installed)-- Install [Python](https://www.python.org/) >= 3.8. (You may already it installed. To see your version, use `python -V` at the command line.)+- Install [Python](https://www.python.org/) >= 3.9. (You may already it installed. To see your version, use `python -V` at the command line.)+- Install [Hatch](https://hatch.pypa.io/latest/install/). Some installation options:+ - `brew install hatch`+ - `pipx install hatch`And you'll need [pre-commit](https://pre-commit.com/) to run some validation checks:```bash-pipx install pre-commit # or `pip install pre-commit` if you have a virtualenv+pipx install pre-commit+# or `pip install pre-commit` if you have a virtualenv+# or `brew install pre-commit````You can optionally install pre-commit hooks to automatically run the validation checks@@ -56,15 +60,22 @@ Be sure to install the dependencies above before building from source.### Build from source-After installing the dependencies, run the following in a fresh Python virtual-environment (such as [venv](https://docs.python.org/3/library/venv.html) or-[virtualenv](https://virtualenv.pypa.io/en/latest/)):+After installing the dependencies, you can use either the traditional method (installing an editable wheel in your current venv) or use Hatch:++Traditional method:```bashmake fe && make py```-`make fe` builds the frontend. `make py` does an [editable install](https://setuptools.pypa.io/en/latest/userguide/development_mode.html) of marimo.+Using Hatch:++```bash+make fe+hatch shell+```++`make fe` builds the frontend. `make py` does an [editable install](https://setuptools.pypa.io/en/latest/userguide/development_mode.html) of marimo, while `hatch shell` creates a Hatch environment with an editable install of marimo.(All `make` commands should be run in the project's root directory.)@@ -117,10 +128,19 @@ make fe-check**Python.**+Using Make:+```bashmake py-check```+Using Hatch:++```bash+hatch run lint+hatch run typecheck:check+```+## TestsWe have frontend unit tests, Python unit tests, and end-to-end tests.@@ -146,12 +166,42 @@ make fe-test### Python-In the root directory, run+Using Make:```bashmake py-test```+#### Using Hatch++**Run a specific tests.**++```bash+hatch run test:test tests/_ast/+```++**Run a specific tests with optional dependencies.**++```bash+hatch run test-optional:test tests/_ast/+```++**Run tests with a specific Python version.**++```bash+hatch run +py=3.10 test:test tests/_ast/+# or+hatch run +py=3.10 test-optional:test tests/_ast/+```++**Run all tests across all Python versions.**++Not recommended since it takes a long time.++```bash+hatch run test:test+```+### End-to-endWe use playwright to write and run end-to-end tests, which exercise both the@@ -176,7 +226,7 @@ make e2eIn `frontend/`:```bash-npx playwright test --ui+pnpm playwright test --ui```**Run a specific test.**@@ -184,15 +234,15 @@ npx playwright test --uiIn `frontend/`:```bash-npx playwright test <filename> --ui+pnpm playwright test <filename> --ui# e.g.-npx playwright test cells.test.ts --ui+pnpm playwright test cells.test.ts --ui```or```bash-npx playwright test --debug <filename>+pnpm playwright test --debug <filename>```## Storybookdiff --git a/Makefile b/Makefileindex 3afa4748a9..007351c075 100644--- a/Makefile+++ b/Makefile@@ -47,7 +47,7 @@ fe-test:.PHONY: e2e# test end-to-ende2e:- cd frontend; npx playwright install; npx playwright test+ cd frontend; pnpm playwright install; pnpm playwright test.PHONY: fe-lintfe-lint:@@ -62,20 +62,21 @@ fe-codegen:cd openapi; pnpm install; pnpm codegen.PHONY: py-check-# check python+# typecheck, lint, format pythonpy-check:- ./scripts/pyfix.sh+ ./scripts/pycheck.sh.PHONY: py-test# test pythonpy-test:- cd marimo && typos && cd - && pytest;+ cd marimo && typos && cd - && hatch run +py=3.12 test-optional:test.PHONY: py-snapshots# update html snapshotspy-snapshots:- pytest tests/_server/templates/test_templates.py- pytest tests/_server/api/endpoints/test_export.py+ hatch run +py=3.12 test:test \+ tests/_server/templates/test_templates.py \+ tests/_server/api/endpoints/test_export.py.PHONY: install-all# install everything; takes a long time due to editable install@@ -84,7 +85,7 @@ install-all: fe py.PHONY: wheel# build wheelwheel:- python -m build+ hatch build.PHONY: storybookstorybook:@@ -95,14 +96,14 @@ storybook:# use make ARGS="-a" docs to force docs to rebuild, useful when# modifying static files / assetsdocs:- sphinx-build $(ARGS) docs/ docs/_build+ hatch run docs:build $(ARGS).PHONY: docs-auto# autobuild docsdocs-auto:- sphinx-autobuild $(ARGS) docs/ docs/_build+ hatch run docs:autobuild $(ARGS).PHONY: docs-clean# remove built docsdocs-clean:- cd docs && make clean+ hatch run docs:cleandiff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yamlindex 9712d85902..c49145838e 100644--- a/frontend/pnpm-lock.yaml+++ b/frontend/pnpm-lock.yaml@@ -1873,7 +1873,6 @@ packages:'@humanwhocodes/[email protected]':resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==}engines: {node: '>=10.10.0'}- deprecated: Use @eslint/config-array instead'@humanwhocodes/[email protected]':resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==}@@ -1881,7 +1880,6 @@ packages:'@humanwhocodes/[email protected]':resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==}- deprecated: Use @eslint/object-schema instead'@iconify/[email protected]':resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==}@@ -3573,7 +3571,6 @@ packages:'@storybook/[email protected]':resolution: {integrity: sha512-JSBZMOrSw/3rlq5YoEI7Qyq703KSNP0Jd+gxTWu3/tP6245mpjn2dXnR8FvqVxCi+FG4lt2kQyPzgsuwEw1SSA==}- deprecated: 'This package has been split into @storybook/addon-styling-webpack and @storybook/addon-themes. More info: https://github.com/storybookjs/addon-styling'hasBin: truepeerDependencies:less: ^3.5.0 || ^4.0.0@@ -3775,7 +3772,6 @@ packages:'@storybook/[email protected]':resolution: {integrity: sha512-L8sXFJUHmrlyU2BsWWZGuAjv39Jl1uAqUHdxmN42JY15M4+XCMjGlArdCCjDe1wpTSW6USYISA9axjZojgtvnw==}- deprecated: In Storybook 8, this package functionality has been integrated to a new package called @storybook/test, which uses Vitest APIs for an improved experience. When upgrading to Storybook 8 with 'npx storybook@latest upgrade', you will get prompted and will get an automigration for the new package. Please migrate when you can.'@storybook/[email protected]':resolution: {integrity: sha512-frBkvH7LF8j23ODaywLK4m4LLscw49oKblkZ+30QZkBAzRf2o3a/QSZW2V1zfBo7ygcXiUJ5bIjh7Y17mMJqbQ==}@@ -4140,7 +4136,6 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-IyNhGHu71jH1jCXTHmafuoAAdsbBON3kDh7u/UUhLmjYgN5TYB54e1R8ckTCiIevl2UuZaCsi9XRxineY5yUjw==}- deprecated: This is a stub types definition. fast-json-stable-stringify provides its own type definitions, so you do not need this installed.'@types/[email protected]':resolution: {integrity: sha512-1eKvCaIBdrD2mmMgy5dwh564rVvfEhZTWVQQGRNn0Nt4ZEnJ0C8oSUCzvMKRA4lGde5oEVo+q2MrTTbV/GHDCQ==}@@ -6292,11 +6287,9 @@ packages:resolution: {integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==}- deprecated: Glob versions prior to v9 are no longer supportedresolution: {integrity: sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==}- deprecated: Glob versions prior to v9 are no longer supportedresolution: {integrity: sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==}@@ -6406,7 +6399,6 @@ packages:resolution: {integrity: sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==}engines: {node: '>=6'}- deprecated: this library is no longer supportedresolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==}@@ -6582,7 +6574,6 @@ packages:resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}- deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}@@ -7385,7 +7376,6 @@ packages:resolution: {integrity: sha512-VAFIOG6rsxoc7q/IaY3jdjmrsuX9f15KlRLYTHmixASBZkZEKC1IFqE2BC5CdhXmK6WLM1Re33z//AGmeRI6FA==}- deprecated: Redundant dependency in your project.resolution: {integrity: sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw==}@@ -8516,7 +8506,6 @@ packages:resolution: {integrity: sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==}engines: {node: '>= 6'}- deprecated: request has been deprecated, see https://github.com/request/request/issues/3142resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}@@ -8581,12 +8570,10 @@ packages:resolution: {integrity: sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==}- deprecated: Rimraf versions prior to v4 are no longer supportedhasBin: trueresolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==}- deprecated: Rimraf versions prior to v4 are no longer supportedhasBin: true@@ -9192,7 +9179,6 @@ packages:resolution: {integrity: sha512-JLFtrhClUH/k/yvsiCXqcWcXaOfO3DgFvHnYb+gS2xlDbjbvkKh6YB1CPilmEV++tH33xw6wCxoYA5g6YLZw/Q==}- deprecated: Use topojson-client, topojson-server or topojson-simplify directly.hasBin: true@@ -9505,7 +9491,6 @@ packages:resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==}- deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.hasBin: truediff --git a/marimo/_cli/sandbox.py b/marimo/_cli/sandbox.pyindex 879d4f8488..593481f843 100644--- a/marimo/_cli/sandbox.py+++ b/marimo/_cli/sandbox.py@@ -136,7 +136,7 @@ def run_in_sandbox(# During development, you can comment this out to install an# editable version of marimo assuming you are in the marimo directory# DO NOT COMMIT THIS WHEN SUBMITTING PRs- # dependencies[index_of_marimo] = "-e .[dev]"+ # dependencies[index_of_marimo] = "-e ."with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt"diff --git a/pyproject.toml b/pyproject.tomlindex 74f6fb2c15..e34c651392 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[build-system]-requires = ["setuptools"]-build-backend = "setuptools.build_meta"+requires = ["hatchling"]+build-backend = "hatchling.build"[project]name = "marimo"@@ -34,7 +34,7 @@ dependencies = [# websockets for use with starlette"websockets >= 10.0.0,<13.0.0",# python <=3.10 compatibility- "typing_extensions>=4.4.0; python_version < \"3.11\"",+ "typing_extensions>=4.4.0; python_version < '3.11'",# for rst parsing; lowerbound determined by awscli requiring < 0.17,"docutils>=0.16.0",# to show RAM, CPU usage, other system utilities@@ -69,82 +69,114 @@ classifiers = [[project.scripts]marimo = "marimo._cli.cli:main"+[project.urls]+homepage = "https://github.com/marimo-team/marimo"+[project.optional-dependencies]-sql = [- "duckdb >= 1.0.0",-]+sql = ["duckdb >= 1.0.0"]dev = ["click <8.1.4", # https://github.com/pallets/click/issues/2558"black~=23.12.1",- "build~=0.10.0",- "types-Pygments~=2.18.0.20240506",- "types-psutil~=5.9.5.20240516",- # For server testing- "httpx~=0.27.0",- # For SQL- "duckdb~=1.1.0",- # For testing mo.ui.chart, dataframes, tables- "pandas>=1.5.3",- "pandas-stubs>=1.5.3.230321",- "pyarrow>=15.0.2,<18",- "pyarrow-stubs>=17.0",# For tracing debugging"opentelemetry-api~=1.26.0","opentelemetry-sdk~=1.26.0",- # For testing mo.image- "pillow~=10.4.0",- "types-Pillow~=10.2.0.20240520",+ # For SQL+ "duckdb>=1.0.0",+ # For linting+ "ruff~=0.6.1",+ # For AI+ "openai~=1.41.1",+]++[tool.hatch]+installer = "uv"++[tool.hatch.version]+path = "marimo/__init__.py"++[tool.hatch.build.targets.sdist]+include = ["/marimo"]+artifacts = ["marimo/_static/"]+exclude = ["marimo/_smoke_tests"]++[tool.hatch.build.targets.wheel]+packages = ["marimo"]+artifacts = ["marimo/_static/"]+exclude = ["marimo/_smoke_tests"]++# Override the default uv version to use the latest version+[tool.hatch.envs.hatch-uv]+dependencies = ["uv>=0.4.17"]++[tool.hatch.envs.default]+features = ["dev"]+python = "3.12"+installer = "uv"+dependencies = [+ "uv>=0.4.17", # so we can bump the version used by hatch+ # Typo checking+ "typos~=1.23.6",+]++[tool.hatch.envs.default.scripts]+lint = "ruff check --fix"+format = "ruff format"++[tool.hatch.envs.typecheck]+python = "3.12"+installer = "uv"+dependencies = [+ "mypy~=1.10.1",+ # Types for mypy"polars~=1.5.0",- "hypothesis~=6.102.1",- "pytest~=8.3.2",- "pytest-codecov~=0.5.1",- "pytest-asyncio~=0.23.8",+ "pyarrow-stubs>=17.0",+ "pandas-stubs>=1.5.3.230321",+ "types-Pillow~=10.2.0.20240520",+ "types-Pygments~=2.18.0.20240506",+ "types-psutil~=5.9.5.20240516","types-Markdown~=3.6.0.20240316","types-PyYAML~=6.0.12.20240808",- "mypy~=1.10.1",- "ruff~=0.6.1",- "typos~=1.23.6",- # For docs- "pypandoc~=1.13",- "autoclasstoc~=1.6.0",- # furo raises an error during docs build when sphinx is upgraded- "sphinx~=7.0.1",- "sphinx-copybutton~=0.5.2",- "sphinx-new-tab-link~=0.5.3",- "sphinx-sitemap~=2.6.0",- "sphinx-design~=0.5.0",- "myst_parser~=3.0.1",- "furo==2024.8.6"]-testcore = [- "click <8.1.4", # https://github.com/pallets/click/issues/2558,- # for server testing+[tool.hatch.envs.typecheck.scripts]+check = "mypy marimo/"++[tool.hatch.envs.test]+extra-dependencies = ["hypothesis~=6.102.1",+ # For server testing"httpx~=0.27.0","pytest~=8.3.2","pytest-codecov~=0.5.1","pytest-asyncio~=0.23.8",]-testoptional = [+[[tool.hatch.envs.test.matrix]]+python = ["3.9","3.10", "3.11", "3.12"]++[tool.hatch.envs.test.scripts]+test = "pytest{env:HATCH_TEST_ARGS:} {args:tests}"+default = "pytest{env:HATCH_TEST_ARGS:} {args:tests}"++[tool.hatch.envs.test-optional]+template = "test"+extra-dependencies = [+ "hypothesis~=6.102.1",+ "httpx~=0.27.0",+ "pytest~=8.3.2",+ "pytest-codecov~=0.5.1",+ "pytest-asyncio~=0.23.8",# For testing mo.ui.chart, table, ..."altair>=5.4.0","pandas>=1.5.3",- "pandas-stubs>=1.5.3.230321",- "geopandas~=0.14.4; python_version > \"3.8\"",- "matplotlib~=3.9.2; python_version > \"3.8\"",- "pyarrow>=15.0.2,<18",- "pyarrow-stubs>=17.0",- "pyarrow-hotfix",+ "geopandas~=0.14.4; python_version > '3.9'",+ # For testing mo.image"pillow~=10.4.0",- "types-Pillow~=10.2.0.20240520",- "polars~=1.5.0","anywidget~=0.9.13","ipython~=8.12.3","openai~=1.41.1",- "ibis-framework[duckdb]~=9.5.0; python_version > \"3.9\"",+ "ibis-framework[duckdb]~=9.5.0; python_version > '3.9'","anthropic==0.34.1","google-generativeai==0.8.2",# exporting as ipynb@@ -152,18 +184,31 @@ testoptional = ["sympy>=1.13.2",]-[project.urls]-homepage = "https://github.com/marimo-team/marimo"+[[tool.hatch.envs.test-optional.matrix]]+python = ["3.9","3.10", "3.11", "3.12"]-[tool.setuptools.dynamic]-version = { attr = "marimo.__version__" }+[tool.hatch.envs.docs]+dependencies = [+ "pypandoc~=1.13",+ "autoclasstoc~=1.6.0",+ # furo raises an error during docs build when sphinx is upgraded+ "sphinx~=7.0.1",+ "sphinx-copybutton~=0.5.2",+ "sphinx-new-tab-link~=0.5.3",+ "sphinx-sitemap~=2.6.0",+ "sphinx-design~=0.5.0",+ "myst_parser~=3.0.1",+ "furo==2024.8.6"+]-[tool.setuptools.packages.find]-# project source is entirely contained in the `marimo` package-include = ["marimo*"]+[tool.hatch.envs.docs.scripts]+build = "sphinx-build {args:docs/ docs/_build}"+autobuild = "sphinx-autobuild {args:docs/ docs/_build}"+clean = "cd docs && make clean"[tool.ruff]line-length=79+include = ["marimo/**/*.py", "tests/**/*.py"]exclude = ["examples","scripts",diff --git a/scripts/pycheck.sh b/scripts/pycheck.shindex 5b11bb1427..4a71deafb8 100755--- a/scripts/pycheck.sh+++ b/scripts/pycheck.sh@@ -1,6 +1,12 @@#!/bin/sh+echo "[check: typos]"+hatch run typos -w+echo "[check: copyright]"+./scripts/pycopyright.shecho "[check: lint]"-ruff check marimo/+hatch run ruff check --fix+echo "[check: format]"+hatch run ruff formatecho "[check: typecheck]"-mypy marimo/+hatch run mypy marimo/diff --git a/scripts/pyfix.sh b/scripts/pyfix.shdeleted file mode 100755index d3c3902b62..0000000000--- a/scripts/pyfix.sh+++ /dev/null@@ -1,12 +0,0 @@-#!/bin/sh--echo "[fix: typos]"-cd marimo && typos -w && cd --echo "[fix: copyright]"-./scripts/pycopyright.sh-echo "[fix: ruff]"-ruff check marimo/ --fix-ruff check tests/ --fix-ruff format marimo/-ruff format tests/-./scripts/pycheck.shdiff --git a/tests/_plugins/ui/_impl/test_table.py b/tests/_plugins/ui/_impl/test_table.pyindex 4aa553c875..639fefeaf3 100644--- a/tests/_plugins/ui/_impl/test_table.py+++ b/tests/_plugins/ui/_impl/test_table.py@@ -487,7 +487,7 @@ def test_table_with_frozen_columns() -> None:@pytest.mark.skipif(not DependencyManager.pandas.has(), reason="Pandas not installed")-def test_table_with_filtered_columns() -> None:+def test_table_with_filtered_columns_pandas() -> None:import pandas as pdtable = ui.table(pd.DataFrame({"a": [1, 2, 3], "b": ["abc", "def", None]}))@@ -500,6 +500,11 @@ def test_table_with_filtered_columns() -> None:)assert result.total_rows == 1++ not DependencyManager.polars.has(), reason="Polars not installed"+)+def test_table_with_filtered_columns_polars() -> None:import polars as pltable = ui.table(pl.DataFrame({"a": [1, 2, 3], "b": ["abc", "def", None]}))diff --git a/tests/_plugins/ui/_impl/utils/test_dataframe_utils.py b/tests/_plugins/ui/_impl/utils/test_dataframe_utils.pyindex c6f77a6a12..598cce8e9b 100644--- a/tests/_plugins/ui/_impl/utils/test_dataframe_utils.py+++ b/tests/_plugins/ui/_impl/utils/test_dataframe_utils.py@@ -10,6 +10,8 @@ from marimo._plugins.ui._impl.tables.utils import get_table_managerHAS_PANDAS = DependencyManager.pandas.has()HAS_NARWHALS = DependencyManager.narwhals.has()+HAS_POLARS = DependencyManager.polars.has()+HAS_PYARROW = DependencyManager.pyarrow.has()def _get_row_headers(@@ -59,7 +61,7 @@ def test_get_row_headers_list() -> None:@pytest.mark.skipif(- not HAS_PANDAS or not HAS_NARWHALS,+ not HAS_PANDAS or not HAS_NARWHALS or not HAS_POLARS or not HAS_PYARROW,reason="optional dependencies not installed",)def test_get_table_manager() -> None:diff --git a/tests/_server/api/endpoints/test_files.py b/tests/_server/api/endpoints/test_files.pyindex c5c374aecc..cdd9cfb40b 100644--- a/tests/_server/api/endpoints/test_files.py+++ b/tests/_server/api/endpoints/test_files.py@@ -13,7 +13,7 @@ from tests._server.mocks import ()if TYPE_CHECKING:- from fastapi.testclient import TestClient, WebSocketTestSession+ from starlette.testclient import TestClient, WebSocketTestSessionSESSION_ID = "session-123"HEADERS = {diff --git a/tests/_server/mocks.py b/tests/_server/mocks.pyindex 581c7ce157..a1af9bdedc 100644--- a/tests/_server/mocks.py+++ b/tests/_server/mocks.py@@ -13,7 +13,7 @@ from marimo._server.tokens import AuthToken, SkewProtectionTokenfrom marimo._utils.marimo_path import MarimoPathif TYPE_CHECKING:- from fastapi.testclient import TestClient+ from starlette.testclient import TestClientdef get_session_manager(client: TestClient) -> SessionManager:diff --git a/marimo/_server/models/test_base.py b/tests/_server/models/test_base.pysimilarity index 100%rename from marimo/_server/models/test_base.pyrename to tests/_server/models/test_base.pydiff --git a/tests/_sql/test_sql.py b/tests/_sql/test_sql.pyindex e01b2b8e49..ddea39ce82 100644--- a/tests/_sql/test_sql.py+++ b/tests/_sql/test_sql.py@@ -86,7 +86,9 @@ def test_applies_limit(mock_replace: MagicMock) -> None:del os.environ["MARIMO_SQL_DEFAULT_LIMIT"][email protected](HAS_DEPS, reason="must be missing deps")+ DependencyManager.duckdb.has(), reason="must be missing duckdb"+)def test_sql_raises_error_without_duckdb():with pytest.raises(ModuleNotFoundError):sql("SELECT * FROM t")