Skip to content

Commit cd9d92e

Browse files
committed
Added ruff
1 parent 2e3b282 commit cd9d92e

6 files changed

Lines changed: 53 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ on: [push, pull_request]
33

44
jobs:
55

6+
static-checks:
7+
name: Static analyis checks
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- name: Check out
11+
uses: actions/checkout@v4
12+
- name: Check source with ruff
13+
uses: astral-sh/ruff-action@v3
14+
with:
15+
args: check --output-format=github
16+
src: ./source
17+
- name: Check tests with ruff
18+
uses: astral-sh/ruff-action@v3
19+
with:
20+
args: check --output-format=github
21+
src: ./tests
22+
623
build:
724
name: Build
825
runs-on: ubuntu-22.04

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ build-backend = "hatchling.build"
2828
[dependency-groups]
2929
dev = [
3030
"mkdocs==1.2.4",
31+
"ruff>=0.11.12",
3132
]
3233

src/docx_generator/adapters/mistletoe/DocxRenderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def render_strikethrough(self, token):
6868

6969
@debug_token_rendering('Rendering Image.')
7070
def render_image(self, token):
71-
if self._image_handler != None:
71+
if self._image_handler is not None:
7272
self._image_handler.set_template(self._template)
7373
image = self._image_handler.add_picture(token.src)
7474
return str(image)

src/docx_generator/docx_generator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from docxtpl import DocxTemplate
2727
from jinja2 import Environment
2828

29-
from docx_generator.adapters.docx.style_adapter import RenderStylesCollection, get_document_render_styles, _BEGIN_STYLE, _END_STYLE, _TAG_STYLE
29+
from docx_generator.adapters.docx.style_adapter import RenderStylesCollection, get_document_render_styles
3030
from docx_generator.adapters.mistletoe.DocxRenderer import DocxRenderer
3131
from docx_generator.exceptions.rendering_error import RenderingError
3232
from docx_generator.filters.filters import Filters
@@ -138,9 +138,10 @@ def generate_docx(self, base_path: str, template_path: str, data: Dict, output_p
138138
full_template_path = self._process_template_path(processed_base_path, template_path)
139139
full_output_path = self._process_output_path(processed_base_path, output_path)
140140

141-
if self._image_handler != None:
141+
if self._image_handler is not None:
142142
self._image_handler.set_base_path(processed_base_path)
143143
self._image_handler.set_output_path(os.path.join(os.path.dirname(full_output_path), "images"))
144144

145-
self._logger.info('Starting new report generation. Base path: {}. Template path: {}. Output path'.format(processed_base_path, full_template_path, full_output_path))
145+
self._logger.info(f'Starting new report generation. Base path: {processed_base_path}. '
146+
f'Template path: {full_template_path}. Output path {full_output_path}')
146147
self._recursive_rendering(processed_base_path, full_template_path, data, full_output_path, 0)

src/docx_generator/globals/picture_globals.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import shutil
2626
import uuid
2727

28-
import urllib3.connection
2928
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
3029
from docxtpl import DocxTemplate, Subdoc
3130

uv.lock

Lines changed: 30 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)