8000 Solve FieldValidationInfo warning by RomainBrault · Pull Request #1342 · copier-org/copier · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Solve FieldValidationInfo warning #1342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions copier/user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from prompt_toolkit.validation import ValidationError
from pydantic import ConfigDict, Field, field_validator
from pydantic.dataclasses import dataclass
from pydantic_core.core_schema import FieldValidationInfo
from pydantic_core.core_schema import ValidationInfo
from pygments.lexers.data import JsonLexer, YamlLexer
from questionary.prompts.common import Choice

Expand Down Expand Up @@ -191,15 +191,15 @@ def _check_var_name(cls, v: str):

@field_validator("type")
@classmethod
def _check_type(cls, v: str, info: FieldValidationInfo):
def _check_type(cls, v: str, info: ValidationInfo):
if v == "":
default_type_name = type(info.data.get("default")).__name__
v = default_type_name if default_type_name in CAST_STR_TO_NATIVE else "yaml"
return v

@field_validator("secret")
@classmethod
def _check_secret_question_default_value(cls, v: bool, info: FieldValidationInfo):
def _check_secret_question_default_value(cls, v: bool, info: ValidationInfo):
if v and info.data["default"] is MISSING:
raise ValueError("Secret question requires a default value")
return v
Expand Down
85 changes: 34 additions & 51 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
flake = false;
};
flake-utils.url = github:numtide/flake-utils;
nixpkgs.url = github:NixOS/nixpkgs;
nixpkgs.url = github:NixOS/nixpkgs/release-23.05;
poetry2nix.url = github:nix-community/poetry2nix;
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
};
Expand Down Expand Up @@ -48,6 +48,9 @@
name = "copier-${version}";
projectDir = ./.;

# Trick poetry-dynamic-versioning into using our version
POETRY_DYNAMIC_VERSIONING_BYPASS = version;

# Test configuration
propagatedNativeBuildInputs = [pkgs.git];
pythonImportsCheck = ["copier"];
Expand Down
Loading
0