Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: acceptance

on:
pull_request:
types: [ opened, synchronize, ready_for_review ]
types: [ opened, synchronize ]
merge_group:
types: [ checks_requested ]
push:
Expand All @@ -18,26 +18,30 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
HATCH_VERBOSE: "2"
HATCH_VERSION: "1.16.5"

jobs:
integration:
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
if: github.event_name == 'pull_request'
environment: account-admin
runs-on: larger
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
python-version: '3.10'
python-version: '3.14'

- name: Install hatch
run: pip install hatch==1.15.0
run: pip install "hatch==${HATCH_VERSION}"

- name: Fetch relevant branches
run: |
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/downstreams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ permissions:
contents: read
pull-requests: write

env:
HATCH_VERBOSE: "2"
HATCH_VERSION: "1.16.5"

jobs:
compatibility:
strategy:
Expand All @@ -31,20 +35,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
# Downstream currently just tests with system python rather than controlling the versions properly.
python-version: '3.10'

- name: Install toolchain
run: |
pip install hatch==1.15.0
pip install "hatch==${HATCH_VERSION}"

- name: Downstreams
uses: databrickslabs/sandbox/downstreams@acceptance/v0.4.2
with:
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,29 @@ permissions:
concurrency:
group: single-acceptance-job-per-repo

env:
HATCH_VERBOSE: "2"
HATCH_VERSION: "1.16.5"

jobs:
integration:
environment: account-admin
runs-on: larger
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
python-version: '3.10'
python-version: '3.14'

- name: Install hatch
run: pip install hatch==1.15.0
run: pip install "hatch==${HATCH_VERSION}"

- name: Run nightly tests
uses: databrickslabs/sandbox/acceptance@acceptance/v0.4.2
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,39 @@ on:
- main

env:
HATCH_VERSION: 1.15.0
HATCH_VERBOSE: "2"
HATCH_VERSION: "1.16.5"

jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pyVersion: [ '3.10', '3.11', '3.12' ]
python: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]
env:
HATCH_ENV: "test.py${{ matrix.python }}"
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
python-version: ${{ matrix.pyVersion }}
# The version under test, as well as Python 3.14 for Hatch.
python-version: |
${{ matrix.python }}
${{ matrix.python != '3.14' && '3.14' || '' }}

- name: Install hatch
run: pip install hatch==$HATCH_VERSION
run: pip install "hatch==${HATCH_VERSION}"

- name: Run unit tests
run: hatch run test
run: make test

- name: Publish test coverage
uses: codecov/codecov-action@v5
Expand All @@ -52,19 +58,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
python-version: 3.10.x
python-version: '3.14'

- name: Install hatch
run: pip install hatch==$HATCH_VERSION
run: pip install "hatch==${HATCH_VERSION}"

- name: Reformat code
run: make fmt
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
tags:
- 'v*'

env:
HATCH_VERBOSE: "2"
HATCH_VERSION: "1.16.5"

jobs:
publish:
runs-on:
Expand All @@ -17,17 +21,17 @@ jobs:
# Used to attach signing artifacts to the published release.
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
python-version: '3.10'
python-version: '3.14'

- name: Build wheels
run: |
pip install hatch==1.15.0
pip install "hatch==${HATCH_VERSION}"
hatch build

- name: Draft release
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea/
.venv/
.venv-*/
*.iml
*.pyc
.pytest_cache
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: clean lint fmt test coverage

clean:
rm -fr .venv clean htmlcov .mypy_cache .pytest_cache .ruff_cache .coverage coverage.xml
rm -fr .venv* clean htmlcov .mypy_cache .pytest_cache .ruff_cache .coverage coverage.xml
rm -fr **/*.pyc

.venv/bin/python:
Expand Down
66 changes: 47 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dynamic = ["version"]
description = 'Python Testing for Databricks'
readme = "README.md"
license-files = { paths = ["LICENSE", "NOTICE"] }
requires-python = ">=3.10"
requires-python = ">=3.10,<3.15"
keywords = ["Databricks", "pytest"]
maintainers = [
{ name = "Serge Smertin", email = "serge.smertin@databricks.com" },
Expand All @@ -36,6 +36,8 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Environment :: Console",
"Framework :: Pytest",
Expand All @@ -50,7 +52,7 @@ classifiers = [
dependencies = [
"databricks-sdk>=0.51.0,<1.0",
"databricks-labs-lsql>=0.10",
"pytest>=8.3",
"pytest>=9.0",
]

[project.entry-points.pytest11]
Expand All @@ -67,48 +69,77 @@ path = "src/databricks/labs/pytester/__about__.py"
[tool.hatch.envs.default]
dependencies = [
"black~=24.3.0",
"coverage[toml]~=7.4.4",
"mypy~=1.11.0",
"pylint~=3.2.2",
"pylint-pytest==2.0.0a0",
"coverage[toml]~=7.13.4",
"mypy~=1.19.1",
"pylint~=4.0.5",
"pylint-pytest==2.0.0a1",
"databricks-labs-pylint~=0.4.0",
"pytest-cov~=4.1.0",
"pytest-mock~=3.14.0",
"pytest-timeout~=2.3.1",
"pytest-xdist~=3.5.0",
"pytest-cov~=7.0.0",
"pytest-mock~=3.15.1",
"pytest-timeout~=2.4.0",
"pytest-xdist~=3.8.0",
"ruff~=0.3.4",
"databricks-connect~=15.4.3",
]

# store virtual env as the child of this folder. Helps VSCode (and PyCharm) to run better
python="3.10"

# Fixed path expected by the `labs` tool to run acceptance tests.
path = ".venv"

[tool.hatch.envs.default.env-vars]
MYPY_CACHE_DIR = ".venv/mypy-cache"
PYTEST_ADDOPTS = "-o cache_dir=.venv/pytest-cache"
RUFF_CACHE_DIR = ".venv/ruff-cache"

[tool.hatch.envs.default.scripts]
test = "pytest -n 4 --cov src --cov-report=xml --timeout 30 tests/unit --durations 20"
coverage = "pytest -n auto --cov src tests/unit --timeout 30 --cov-report=html --durations 20"
integration = "pytest -n 10 --cov src tests/integration --durations 20"
fmt = ["black . --extend-exclude 'tests/unit/source_code/samples/'",
"ruff check . --fix",
"mypy --disable-error-code 'annotation-unchecked' --disable-error-code import-untyped --enable-incomplete-feature=NewGenericSyntax --exclude 'tests/resources/*' --exclude dist .",
"mypy --disable-error-code 'annotation-unchecked' --disable-error-code import-untyped --exclude 'tests/resources/*' --exclude dist .",
"pylint --output-format=colorized -j 0 src tests"]
verify = ["black --check . --extend-exclude 'tests/unit/source_code/samples/'",
"ruff check .",
"mypy --exclude 'tests/resources/*' --exclude dist . --enable-incomplete-feature=NewGenericSyntax",
"mypy --exclude 'tests/resources/*' --exclude dist .",
"pylint --output-format=colorized -j 0 src tests"]
lint = ["pylint --output-format=colorized -j 0 src tests"]

[tool.hatch.envs.test.env-vars]
MYPY_CACHE_DIR = ".venv-py{matrix:python}/mypy-cache"
PYTEST_ADDOPTS = "-o cache_dir=.venv-py{matrix:python}/pytest-cache"
RUFF_CACHE_DIR = ".venv-py{matrix:python}/ruff-cache"

[tool.hatch.envs.test.overrides]
matrix.python.path = [
# Sadly no way to interpolate this.
{ value = ".venv-py3.10", if = ["3.10" ]},
{ value = ".venv-py3.11", if = ["3.11" ]},
{ value = ".venv-py3.12", if = ["3.12" ]},
{ value = ".venv-py3.13", if = ["3.13" ]},
{ value = ".venv-py3.14", if = ["3.14" ]}
]

[[tool.hatch.envs.test.matrix]]
python = [
"3.10",
"3.11",
"3.12",
"3.13",
"3.14",
]

[tool.pytest.ini_options]
# TODO: remove `-p no:warnings`
addopts = "--no-header -p no:warnings"
cache_dir = ".venv/pytest-cache"

[tool.black]
target-version = ["py310"]
line-length = 120
skip-string-normalization = true

[tool.ruff]
cache-dir = ".venv/ruff-cache"
target-version = "py310"
line-length = 120

Expand Down Expand Up @@ -267,10 +298,6 @@ py-version = "3.10"
# source root.
# source-roots =

# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode = true

# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
# unsafe-load-any-extension =
Expand Down Expand Up @@ -443,6 +470,7 @@ bad-functions = ["map", "input"]

# Maximum number of arguments for function / method.
max-args = 9
max-positional-arguments = 9

# Maximum number of attributes for a class (see R0902).
max-attributes = 11
Expand Down
6 changes: 1 addition & 5 deletions src/databricks/labs/pytester/fixtures/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ def inner(k=16) -> str:
T = TypeVar("T")


def factory(
name: str,
create: Callable[..., T],
remove: Callable[[T], None],
) -> Generator[Callable[..., T], None, None]:
def factory(name: str, create: Callable[..., T], remove: Callable[[T], None]) -> Generator[Callable[..., T]]:
"""
Factory function for creating fixtures.

Expand Down
Loading
Loading