From 44248341b7565e574e1f40090ba23009cddcc748 Mon Sep 17 00:00:00 2001 From: Arsene Tripard Date: Fri, 24 May 2024 15:37:46 +0200 Subject: [PATCH] Fix for python 3.9 and Pydantic: keep evaluation of type annotation even with from future import annotations --- generators/app/templates/common/pyproject.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/generators/app/templates/common/pyproject.toml b/generators/app/templates/common/pyproject.toml index dbac878..514a754 100644 --- a/generators/app/templates/common/pyproject.toml +++ b/generators/app/templates/common/pyproject.toml @@ -110,6 +110,13 @@ runtime-evaluated-base-classes = ["pydantic.BaseModel"] # Allow missing docstrings for tests "tests/**/*.py" = ["D1"] +<% if (pythonVersion[0:3] == "3.9") { -%> +[tool.ruff.lint.pyupgrade] +# Preserve types, even if a file imports `from __future__ import annotations`. +# see https://docs.astral.sh/ruff/settings/#lintpyupgrade +keep-runtime-typing = true +<% } -%> + ## mypy [tool.mypy]