Skip to content

Fix "failed to parse year in date -1 week-" error#26

Open
brivadeneira wants to merge 1 commit intotedivm:mainfrom
brivadeneira:main
Open

Fix "failed to parse year in date -1 week-" error#26
brivadeneira wants to merge 1 commit intotedivm:mainfrom
brivadeneira:main

Conversation

@brivadeneira
Copy link

@brivadeneira brivadeneira commented Mar 20, 2026

Fix uv "failed to parse year in date -1 week-" error

Problem
uv couldn't parse static "1 week" in pyproject.toml exclude-newer, causing TOML errors and failed make all/chores during cookiecutter generation.

Solution

  • hooks/pre_gen_project.py: Dynamic date calculation(datetime.now() - timedelta(days=7)).isoformat()one_week_calc injected into cookiecutter.json
    - pyproject.toml: {{ cookiecutter.one_week_calc | default('2026-03-13T00:00:00Z') }}

Files Changed

  • hooks/pre_gen_project.py : Dynamic date logic
  • {{cookiecutter.__package_slug}}/pyproject.toml Templated date

Before

  • make all, uv lock ,TOML parse error, dapperdata crashes
Running 'make all'
warning: Failed to parse `pyproject.toml` during settings discovery:
  TOML parse error at line 78, column 17
     |
  78 | exclude-newer = "1 week"
     |                 ^^^^^^^^
  failed to parse year in date "1 week": failed to parse "1 we" as year (a four digit integer): invalid digit, expected 0-9 but got  

After

  • make all, uv lock, success
cookiecutter robs_awesome_python_template/

package_name []: testing_week_fix
(...)
python_version [3.14]: 3.11
(...)
Setting dynamic variable 'one_week_calc' to last week: 2026-03-13T15:36:04

Running 'make all'
Using CPython 3.11.11 interpreter at: /usr/bin/python3.11
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
Resolved 48 packages in 443ms
Resolved 48 packages in 0.60ms
      Built testing_week_fix @ file:///home/bibiana/mk
❯ tail testing_week_fix/pyproject.toml
disallow_untyped_calls = false
disallow_untyped_defs = true
no_implicit_optional = true
plugins = ["pydantic.mypy"]
strict_optional = true
warn_return_any = true
warn_unused_ignores = true

[tool.uv]
exclude-newer = "2026-03-13T00:00:00Z"

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.

1 participant