Skip to content

Create dbt-autofix-jinja package#325

Open
davidharting wants to merge 27 commits intomainfrom
davidharting/291/jinja-parsing-subpacke
Open

Create dbt-autofix-jinja package#325
davidharting wants to merge 27 commits intomainfrom
davidharting/291/jinja-parsing-subpacke

Conversation

@davidharting
Copy link
Collaborator

Description

Resolves #291.
Move code related to jinja-parsing to it's own sub-package.

I tried to keep this minimal.

  • initialized a new workspace package
  • moved jinja code over there
  • Updated dbt-autofix and test imports to use the new package!
  • Updated wheel_installation test to inspect the build artifacts for the new package

Decisions

  • Name: dbt-autofix-jinja. I wanted it to be clear that this package supports autofix, and is not a general jinja package maintained by dbt. If we had dbt-jinja, or similar, I'm afraid people would assume it's like dbt-flavored jinja, or our own official jinja parser or something.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • internal chnage

Checklist

  • Ran uvx ruff@0.14.14 check . --config pyproject.toml
  • Ran uvx ruff@0.14.14 format --config pyproject.toml
  • If this is a bug fix:
    • Updated integration tests with bug repro
    • Linked to bug report ticket
  • Added unit tests if needed
  • Updated unit tests if needed
  • Tests passed when run locally

davidharting and others added 24 commits February 10, 2026 10:42
Migrate both packages (dbt-autofix and dbt-fusion-package-tools) from
pdm-backend to hatchling with uv-dynamic-versioning for git-based
dynamic versioning. This removes custom Python build hooks in favor of
declarative TOML configuration.

Changes:
- Replace pdm-backend build-system with hatchling + uv-dynamic-versioning
  in both pyproject.toml files
- Delete pdm_build.py (root) and packages/dbt_fusion_package_tools/pdm_build.py
  which contained custom version formatting and dependency pinning logic
- Configure [tool.hatch.metadata.hooks.uv-dynamic-versioning] to template
  dbt-fusion-package-tools=={{ version }} at build time, replacing the
  pdm_build_initialize() hook that conditionally pinned the dependency

Tradeoffs and things to know:

The hatch metadata hook requires that `dependencies` be listed in
`dynamic` and NOT appear in [project]. This means ALL dependencies —
not just the templated dbt-fusion-package-tools — had to move from
[project].dependencies into the [tool.hatch.metadata.hooks.uv-dynamic-versioning]
dependencies list.

As a consequence, `uv add <pkg>` no longer works for the root dbt-autofix
package. New dependencies must be manually added to the
[tool.hatch.metadata.hooks.uv-dynamic-versioning].dependencies list in
pyproject.toml, then `uv lock` run to update the lock file. `uv add`
still works for the dbt-fusion-package-tools sub-package since it does
not use the metadata hook.

The old pdm_build.py only pinned dbt-fusion-package-tools on "real
releases" (skipping .post, .dev, rc, alpha, beta versions). The new
{{ version }} template always pins to the resolved version. This is
acceptable because in practice, only tagged releases are published to
PyPI, and the version will always resolve correctly in that context.

Local development is unaffected — uv workspace source resolution
(`[tool.uv.sources]` with `workspace = true`) still takes precedence
over the declared dependency version, so local changes to
dbt-fusion-package-tools are picked up automatically by dbt-autofix
during development.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per the uv-dynamic-versioning tips documentation [1]:

- Set fallback-version = "0.0.0" so builds don't fail in non-git
  contexts (e.g. Dependabot running `uv lock --upgrade-package` in
  a shallow clone that lacks git tags).

- Set cache-keys with git commit and tag tracking so uv invalidates
  its aggressive metadata cache when git state changes. Without this,
  uv may serve stale version metadata after new tags or commits.

[1] https://github.com/ninoseki/uv-dynamic-versioning/blob/main/docs/tips.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test_core_1_10_installation and test_core_1_12_installation nox
sessions used `uv add` to install dbt-core into the test venv. This
fails now because [project].dependencies is dynamic (managed by the
uv-dynamic-versioning metadata hook), and `uv add` tries to write
to [project].dependencies which conflicts with the dynamic field.

Replace `uv add` with `uv pip install` since these sessions only need
dbt-core present in the venv to verify compatibility — they don't need
it as a permanent project dependency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The old session ran `pre-commit try-repo .` which fails with the
uv-dynamic-versioning metadata hook: the hook pins
dbt-fusion-package-tools=={version}, and in dev the version (e.g.
0.18.7.post11.dev0+e7aee63) doesn't exist on PyPI. This is not a
real-world problem — users always pin a tagged release in their
pre-commit config, where the version exists on PyPI.

The new test_wheel_installation session exercises more than the old one:
1. Builds both wheels via `uv build --all`
2. Inspects the dbt-autofix wheel to verify pre_commit_hooks/ is included
3. Verifies the metadata contains dbt-fusion-package-tools=={version}
4. Installs both wheels in an isolated (non-workspace) venv
5. Runs the CLI entry point (dbt-autofix --help)
6. Runs the pre-commit hook entry point (python -m pre_commit_hooks.check_deprecations)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
l is too ambiguous
I do think it's still a good quality check to keep before we upload to
pypi. Let's fully build the wheel and make sure it contains what we
think it will
This mirrors what we were doing with our pdm script but using dunami's
declarative config. Great find Chaya!
Create a local-only git tag. Build wheels. Test that the tag was used!

Now both the dev build and release build flows are tested - i.e., both
sides of the jinja if/else for our dynamic versions

Had to refactor to the wheel creation / installation logic to share
between both tests
ran this command:
 ❯ uv init packages/dbt-autofix-jinja --name dbt-autofix-jinja --package
--lib --description "Jinja utilities to support dbt-autofix"
--build-backend hatch

will need to be customized
maintainers, authors, and homepage
Now assert that both packages are built and have the correct version
(unpinned for dev, pinned to expected version based on git tag for
release)
@davidharting davidharting requested a review from chayac February 11, 2026 20:39
We were re-exporting everything at first, but I want to be much more
careful.

Tests import from subpackages where needed.

But my goal is for dbt-autofix to only need to import from top-level
@davidharting davidharting marked this pull request as ready for review February 11, 2026 20:46
@davidharting davidharting changed the title Davidharting/291/jinja parsing subpacke Create dbt-autofix-jinja package Feb 11, 2026
Base automatically changed from davidharting/292/remove-pdm-build to main February 17, 2026 20:54
davidharting and others added 2 commits February 21, 2026 13:37
Matches the same setting in dbt-fusion-package-tools and root pyproject.toml,
which suppresses the commit ID from version strings — required for TestPyPI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create subpackage for Jinja parsing

1 participant