refactor cli.py and data_models.py

This commit is contained in:
Sina Atalay 2024-02-14 18:03:13 +01:00
parent b00a3779a6
commit 910e024005
2 changed files with 4 additions and 10 deletions

View File

@ -110,11 +110,11 @@ def handle_validation_error(exception: pydantic.ValidationError):
end_date_error_is_found = False end_date_error_is_found = False
errors = exception.errors() errors = exception.errors()
# Check if there are nested errors and flatten them: # Check if this is a section error. If it is, we need to
# This is needed because of validate_section_input function. We need to tell the # This is needed because how dm.validate_section_input function raises an exception.
# users what is the entry type RenderCV is looking for, for the given section. # This is done to tell the user which which EntryType RenderCV excepts to see.
for error_object in errors.copy(): for error_object in errors.copy():
if "ctx" in error_object: if "Please check your entries" in error_object["msg"] and "ctx" in error_object:
location = error_object["loc"] location = error_object["loc"]
ctx_object = error_object["ctx"] ctx_object = error_object["ctx"]
if "error" in ctx_object: if "error" in ctx_object:

View File

@ -1126,8 +1126,6 @@ def get_a_sample_data_model(name: str) -> RenderCVDataModel:
position="Your Position", position="Your Position",
date="My Whole Life", date="My Whole Life",
location="USA", location="USA",
url="https://yourcompany.com", # type: ignore
url_text="view company website",
highlights=[ highlights=[
"Did something great.", "Did something great.",
"Did something else great.", "Did something else great.",
@ -1158,8 +1156,6 @@ def get_a_sample_data_model(name: str) -> RenderCVDataModel:
name="Your Project", name="Your Project",
location="Istanbul, Turkey", location="Istanbul, Turkey",
date="2015-01", date="2015-01",
url="https://yourproject.com", # type: ignore
url_text="view details",
highlights=[ highlights=[
"Did something **great**.", "Did something **great**.",
"Did *something* else great.", "Did *something* else great.",
@ -1186,8 +1182,6 @@ def get_a_sample_data_model(name: str) -> RenderCVDataModel:
position="Your Position", position="Your Position",
date="My Whole Life", date="My Whole Life",
location="USA", location="USA",
url="https://yourcompany.com", # type: ignore
url_text="view company website",
highlights=[ highlights=[
"Did something great.", "Did something great.",
"Did something else great.", "Did something else great.",