From 1fc7b3a5521adbd4b32e8b592a339361f006c0d5 Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Fri, 5 Jul 2024 17:22:53 +0300 Subject: [PATCH] sort imports and format code --- docs/update_entry_figures.py | 2 +- rendercv/cli/commands.py | 2 +- rendercv/cli/printer.py | 8 ++++---- rendercv/data/__init__.py | 4 ++-- rendercv/data/models/__init__.py | 2 +- rendercv/data/models/base.py | 1 + rendercv/data/models/curriculum_vitae.py | 2 +- rendercv/data/models/entry_types.py | 6 +++--- rendercv/data/models/rendercv_data_model.py | 1 - rendercv/renderer/__init__.py | 2 +- rendercv/renderer/renderer.py | 1 + tests/conftest.py | 2 +- tests/test_cli.py | 2 +- tests/test_reader.py | 10 ++++++---- tests/test_renderer.py | 3 +-- 15 files changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/update_entry_figures.py b/docs/update_entry_figures.py index 332fbb01..1c876d92 100644 --- a/docs/update_entry_figures.py +++ b/docs/update_entry_figures.py @@ -228,7 +228,7 @@ def generate_entry_figures(): ) # Convert pdf to an image - png_file_path = renderer.render_a_markdown_file(output_pdf_file_path)[0] + png_file_path = renderer.render_pngs_from_pdf(output_pdf_file_path)[0] desired_png_file_path = output_pdf_file_path.with_suffix(".png") # If the image exists, remove it diff --git a/rendercv/cli/commands.py b/rendercv/cli/commands.py index 5ff70cca..864d3402 100644 --- a/rendercv/cli/commands.py +++ b/rendercv/cli/commands.py @@ -39,7 +39,6 @@ def cli_command_render( input_file_name: Annotated[ str, typer.Argument(help="Name of the YAML input file.") ], - extra_data_model_override_argumets: typer.Context, use_local_latex_command: Annotated[ Optional[str], typer.Option( @@ -133,6 +132,7 @@ def cli_command_render( ' [cyan bold]--cv.phone "123-456-7890"[/cyan bold].', ), ] = None, + extra_data_model_override_argumets: typer.Context = None, # type: ignore ): """Render a CV from a YAML input file.""" printer.welcome() diff --git a/rendercv/cli/printer.py b/rendercv/cli/printer.py index 61d71533..c74ca4ac 100644 --- a/rendercv/cli/printer.py +++ b/rendercv/cli/printer.py @@ -10,14 +10,14 @@ import pydantic import rich import rich.live +import rich.panel +import rich.progress +import rich.table +import rich.text import ruamel.yaml import ruamel.yaml.parser import typer from rich import print -import rich.table -import rich.progress -import rich.text -import rich.panel from .. import __version__ from . import utilities diff --git a/rendercv/data/__init__.py b/rendercv/data/__init__.py index acf6a321..25742d66 100644 --- a/rendercv/data/__init__.py +++ b/rendercv/data/__init__.py @@ -28,13 +28,13 @@ OneLineEntry, PublicationEntry, RenderCVDataModel, + SectionContents, SocialNetwork, + available_entry_type_names, available_social_networks, available_theme_options, available_themes, format_date, - SectionContents, - available_entry_type_names, ) from .reader import read_input_file diff --git a/rendercv/data/models/__init__.py b/rendercv/data/models/__init__.py index 28ca0234..19dc81ef 100644 --- a/rendercv/data/models/__init__.py +++ b/rendercv/data/models/__init__.py @@ -23,9 +23,9 @@ from .computers import format_date from .curriculum_vitae import ( CurriculumVitae, + SectionContents, SocialNetwork, available_social_networks, - SectionContents, ) from .design import available_theme_options, available_themes from .entry_types import ( diff --git a/rendercv/data/models/base.py b/rendercv/data/models/base.py index d061a548..99c0907f 100644 --- a/rendercv/data/models/base.py +++ b/rendercv/data/models/base.py @@ -5,6 +5,7 @@ import pydantic + class RenderCVBaseModel(pydantic.BaseModel): """This class is the parent class of all the data models in RenderCV. It has only one difference from the default `pydantic.BaseModel`: It raises an error if an diff --git a/rendercv/data/models/curriculum_vitae.py b/rendercv/data/models/curriculum_vitae.py index 1dc63dc4..a720f7a9 100644 --- a/rendercv/data/models/curriculum_vitae.py +++ b/rendercv/data/models/curriculum_vitae.py @@ -157,7 +157,7 @@ def get_entry_type_name_and_section_validator( entry_type_name = entry.__class__.__name__ section_type = create_a_section_validator(entry.__class__) - return entry_type_name, section_type # type: ignore + return entry_type_name, section_type # type: ignore def validate_a_section( diff --git a/rendercv/data/models/entry_types.py b/rendercv/data/models/entry_types.py index 8aa4a086..1576a84a 100644 --- a/rendercv/data/models/entry_types.py +++ b/rendercv/data/models/entry_types.py @@ -70,7 +70,7 @@ def validate_start_and_end_date_fields( elif date != "present": # Validate the date: - computers.get_date_object(date) + computers.get_date_object(date) return date @@ -243,7 +243,7 @@ class PublicationEntryBase(RenderCVBaseModel): description="The journal or conference name.", ) - @pydantic.model_validator(mode="after") # type: ignore + @pydantic.model_validator(mode="after") # type: ignore def ignore_url_if_doi_is_given(self) -> "PublicationEntryBase": """Check if DOI is provided and ignore the URL if it is provided.""" doi_is_provided = self.doi is not None @@ -273,7 +273,7 @@ def clean_url(self) -> str: url_is_provided = self.url is not None if url_is_provided: - return computers.make_a_url_clean(self.url) # type: ignore + return computers.make_a_url_clean(self.url) # type: ignore else: return "" diff --git a/rendercv/data/models/rendercv_data_model.py b/rendercv/data/models/rendercv_data_model.py index 40e27ab5..b4243adf 100644 --- a/rendercv/data/models/rendercv_data_model.py +++ b/rendercv/data/models/rendercv_data_model.py @@ -8,7 +8,6 @@ import pydantic from ...themes.classic import ClassicThemeOptions - from .base import RenderCVBaseModel from .curriculum_vitae import CurriculumVitae from .design import RenderCVDesign diff --git a/rendercv/renderer/__init__.py b/rendercv/renderer/__init__.py index 9cc7734d..de65141a 100644 --- a/rendercv/renderer/__init__.py +++ b/rendercv/renderer/__init__.py @@ -15,8 +15,8 @@ render_a_latex_file, render_a_latex_file_and_copy_theme_files, render_a_markdown_file, - render_an_html_from_markdown, render_a_pdf_from_latex, + render_an_html_from_markdown, render_pngs_from_pdf, ) diff --git a/rendercv/renderer/renderer.py b/rendercv/renderer/renderer.py index 04d413bf..0309ba5b 100644 --- a/rendercv/renderer/renderer.py +++ b/rendercv/renderer/renderer.py @@ -12,6 +12,7 @@ from typing import Optional import fitz + import markdown from .. import data diff --git a/tests/conftest.py b/tests/conftest.py index ac72041a..31400f78 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,8 +15,8 @@ import pypdf import pytest -from rendercv.renderer import templater from rendercv import data +from rendercv.renderer import templater # RenderCV is being tested by comparing the output to reference files. Therefore, # reference files should be updated when RenderCV is updated in a way that changes diff --git a/tests/test_cli.py b/tests/test_cli.py index 40a1e8ac..7bed7fd1 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,8 +1,8 @@ import os +import re import shutil import subprocess import sys -import re from datetime import date as Date import pydantic diff --git a/tests/test_reader.py b/tests/test_reader.py index 4fc1a42d..df0186d8 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -11,10 +11,12 @@ from rendercv import data as data from rendercv.data import generator -from rendercv.data.models import computers -from rendercv.data.models import locale_catalog -from rendercv.data.models import curriculum_vitae -from rendercv.data.models import entry_types +from rendercv.data.models import ( + computers, + curriculum_vitae, + entry_types, + locale_catalog, +) from .conftest import update_testdata diff --git a/tests/test_renderer.py b/tests/test_renderer.py index 9a4da37b..f8e50824 100644 --- a/tests/test_renderer.py +++ b/tests/test_renderer.py @@ -8,8 +8,7 @@ import pytest import time_machine -from rendercv import data -from rendercv import renderer +from rendercv import data, renderer from rendercv.renderer import templater folder_name_dictionary = {