diff --git a/docs/update_entry_figures.py b/docs/update_entry_figures.py index 0c14d15..5ceeda2 100644 --- a/docs/update_entry_figures.py +++ b/docs/update_entry_figures.py @@ -5,14 +5,14 @@ example entries found in are coming from this script. """ -import tempfile -import pathlib import io +import pathlib import shutil +import tempfile from typing import Any -import ruamel.yaml import pdfCropMargins +import ruamel.yaml import rendercv.data_models as dm import rendercv.renderer as r diff --git a/docs/update_examples.py b/docs/update_examples.py index 30a5fd3..d0accdc 100644 --- a/docs/update_examples.py +++ b/docs/update_examples.py @@ -1,7 +1,7 @@ """This script generates the `examples` folder in the repository root.""" -import pathlib import os +import pathlib import shutil import rendercv.cli as cli diff --git a/rendercv/cli.py b/rendercv/cli.py index 99b200e..ae778be 100644 --- a/rendercv/cli.py +++ b/rendercv/cli.py @@ -5,32 +5,31 @@ This module contains the functions and classes that handle the command line inte output. """ -import json -import urllib.request -import pathlib -from typing import Annotated, Callable, Optional -import re import functools -import shutil +import json import os +import pathlib +import re +import shutil +import urllib.request +from typing import Annotated, Callable, Optional -from rich import print +import jinja2 +import pydantic import rich.console -import rich.panel import rich.live +import rich.panel +import rich.progress import rich.table import rich.text -import rich.progress -import pydantic import ruamel.yaml import ruamel.yaml.parser import typer -import jinja2 +from rich import print +from . import __version__ from . import data_models as dm from . import renderer as r -from . import __version__ - app = typer.Typer( rich_markup_mode="rich", diff --git a/rendercv/data_models.py b/rendercv/data_models.py index 22af173..be03e5a 100644 --- a/rendercv/data_models.py +++ b/rendercv/data_models.py @@ -13,27 +13,27 @@ has provided a valid RenderCV input. This is achieved using during the data classes' initialization. """ -from datetime import date as Date -from typing import Literal, Any, Type, Annotated, Optional, get_args -import importlib -import importlib.util -import importlib.machinery import functools -import json -import re -import pathlib -import warnings -import annotated_types as at +import importlib +import importlib.machinery +import importlib.util import io +import json +import pathlib +import re +import warnings +from datetime import date as Date +from typing import Annotated, Any, Literal, Optional, Type, get_args +import annotated_types as at import pydantic import pydantic_extra_types.phone_numbers as pydantic_phone_numbers import ruamel.yaml from .themes.classic import ClassicThemeOptions +from .themes.engineeringresumes import EngineeringresumesThemeOptions from .themes.moderncv import ModerncvThemeOptions from .themes.sb2nov import Sb2novThemeOptions -from .themes.engineeringresumes import EngineeringresumesThemeOptions # Disable Pydantic warnings: warnings.filterwarnings("ignore") diff --git a/rendercv/renderer.py b/rendercv/renderer.py index faff180..75b5b55 100644 --- a/rendercv/renderer.py +++ b/rendercv/renderer.py @@ -9,20 +9,19 @@ distribution. The markdown file is rendered into an HTML file with `markdown` pa The PDF files are rendered into PNG files with `PyMuPDF`/`fitz` package. """ -import subprocess -import re -import pathlib -import importlib.resources -import shutil -import sys import copy +import importlib.resources +import pathlib +import re +import shutil +import subprocess +import sys from datetime import date as Date -from typing import Optional, Any +from typing import Any, Optional +import fitz import jinja2 import markdown -import fitz - from . import data_models as dm @@ -386,6 +385,7 @@ def escape_latex_characters(latex_string: str, strict: bool = True) -> str: for i, link in enumerate(links): placeholder = link[0] escaped_placeholder = placeholder.translate(strict_translation_map) + escaped_placeholder = escaped_placeholder.translate(translation_map) url = link[1] original_link = f"[{placeholder}]({url})" diff --git a/rendercv/themes/__init__.py b/rendercv/themes/__init__.py index 6b8e282..f78a760 100644 --- a/rendercv/themes/__init__.py +++ b/rendercv/themes/__init__.py @@ -3,7 +3,7 @@ are encouraged to inherit from these data models and add their own options, to a code duplication. """ -from typing import Literal, Annotated +from typing import Annotated, Literal import pydantic import pydantic_extra_types.color as pydantic_color diff --git a/rendercv/themes/classic/__init__.py b/rendercv/themes/classic/__init__.py index 59fcddd..8171613 100644 --- a/rendercv/themes/classic/__init__.py +++ b/rendercv/themes/classic/__init__.py @@ -2,7 +2,7 @@ from typing import Literal import pydantic -from .. import ThemeOptions, EntryAreaMargins, Margins, LaTeXDimension +from .. import EntryAreaMargins, LaTeXDimension, Margins, ThemeOptions class EntryAreaMarginsForClassic(EntryAreaMargins): diff --git a/rendercv/themes/engineeringresumes/__init__.py b/rendercv/themes/engineeringresumes/__init__.py index 6317ef4..24ac002 100644 --- a/rendercv/themes/engineeringresumes/__init__.py +++ b/rendercv/themes/engineeringresumes/__init__.py @@ -4,12 +4,12 @@ import pydantic import pydantic_extra_types.color as pydantic_color from .. import ( - ThemeOptions, EntryAreaMargins, - HighlightsAreaMargins, HeaderMargins, - Margins, + HighlightsAreaMargins, LaTeXDimension, + Margins, + ThemeOptions, ) diff --git a/rendercv/themes/sb2nov/__init__.py b/rendercv/themes/sb2nov/__init__.py index 0c8aafe..c2d6648 100644 --- a/rendercv/themes/sb2nov/__init__.py +++ b/rendercv/themes/sb2nov/__init__.py @@ -2,7 +2,7 @@ from typing import Literal import pydantic -from .. import ThemeOptions, LaTeXDimension +from .. import LaTeXDimension, ThemeOptions class Sb2novThemeOptions(ThemeOptions): diff --git a/tests/conftest.py b/tests/conftest.py index 20731c9..efe6672 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,22 +1,22 @@ """This module contains fixtures and other helpful functions for the tests.""" -import pathlib import copy -import typing -import itertools import filecmp -from typing import Optional +import itertools import os +import pathlib import shutil +import typing +from typing import Optional -import pypdf import jinja2 -import pytest import pydantic import pydantic_extra_types.phone_numbers as pydantic_phone_numbers +import pypdf +import pytest -from rendercv import data_models as dm import rendercv.renderer as r +from rendercv import data_models as dm # 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 7d5191b..55f5bb7 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -5,8 +5,8 @@ import sys from datetime import date as Date import pydantic -import ruamel.yaml import pytest +import ruamel.yaml import typer.testing import rendercv.cli as cli @@ -580,8 +580,8 @@ def test_get_latest_version_number_from_pypi(): def test_if_welcome_prints_new_version_available(monkeypatch): monkeypatch.setattr(cli, "get_latest_version_number_from_pypi", lambda: "99999") - import io import contextlib + import io with contextlib.redirect_stdout(io.StringIO()) as f: cli.welcome() diff --git a/tests/test_data_models.py b/tests/test_data_models.py index f4d127c..ab45cf1 100644 --- a/tests/test_data_models.py +++ b/tests/test_data_models.py @@ -1,14 +1,14 @@ -from datetime import date as Date +import io import json import os -import io import re import shutil +from datetime import date as Date import pydantic import pytest -import time_machine import ruamel.yaml +import time_machine from rendercv import data_models as dm diff --git a/tests/test_renderer.py b/tests/test_renderer.py index 9d9d86f..9ff4aa0 100644 --- a/tests/test_renderer.py +++ b/tests/test_renderer.py @@ -1,15 +1,15 @@ -import math -import shutil import copy -import pathlib +import math import os +import pathlib +import shutil -import pytest import jinja2 +import pytest import time_machine -from rendercv import renderer as r from rendercv import data_models as dm +from rendercv import renderer as r folder_name_dictionary = { "rendercv_empty_curriculum_vitae_data_model": "empty", @@ -97,12 +97,12 @@ def test_markdown_file_class(tmp_path, rendercv_data_model, jinja2_environment): ("##%%&&~~", "\\#\\#\\%\\%\\&\\&\\textasciitilde{}\\textasciitilde{}"), ( ( - "[link_test](you shouldn't escape whatever is in here & % # ~) [second" + "[link_test#](you shouldn't escape whatever is in here & % # ~) [second" " link](https://myurl.com)" ), ( - "[link\\_test](you shouldn't escape whatever is in here & % # ~) [second" - " link](https://myurl.com)" + "[link\\_test\\#](you shouldn't escape whatever is in here & % # ~)" + " [second link](https://myurl.com)" ), ), ("$a=5_4^3$", "$a=5_4^3$"), diff --git a/tests/testdata/test_copy_theme_files_to_output_directory_custom_theme/dummytheme/__init__.py b/tests/testdata/test_copy_theme_files_to_output_directory_custom_theme/dummytheme/__init__.py index ce07e49..cccf3f9 100644 --- a/tests/testdata/test_copy_theme_files_to_output_directory_custom_theme/dummytheme/__init__.py +++ b/tests/testdata/test_copy_theme_files_to_output_directory_custom_theme/dummytheme/__init__.py @@ -4,4 +4,4 @@ import pydantic class DummythemeThemeOptions(pydantic.BaseModel): - theme: Literal['dummytheme'] + theme: Literal["dummytheme"]