From 2d375bc135f15403137a6322568a2e572aff3831 Mon Sep 17 00:00:00 2001 From: Agathe Porte <989521+gagath@users.noreply.github.com> Date: Sun, 4 Aug 2024 22:39:50 +0900 Subject: [PATCH] tasks.py.jinja2: optimize imports When opening the generated tasks.py file with a Python linter enabled, some imports will be marked as unecessary depending on the options passed to pelican-quickstart. Add if statements around the optional imports so they are used only when necessary. --- pelican/tools/templates/tasks.py.jinja2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pelican/tools/templates/tasks.py.jinja2 b/pelican/tools/templates/tasks.py.jinja2 index 1a0f02d1..26af6f0d 100644 --- a/pelican/tools/templates/tasks.py.jinja2 +++ b/pelican/tools/templates/tasks.py.jinja2 @@ -2,11 +2,15 @@ import os import shlex import shutil import sys +{% if github %} import datetime +{% endif %} from invoke import task from invoke.main import program +{% if cloudfiles %} from invoke.util import cd +{% endif %} from pelican import main as pelican_main from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer from pelican.settings import DEFAULT_CONFIG, get_settings_from_file