Skip to content

Commit 3c0692c

Browse files
committed
lint fix for readthedocs.doc_builder
1 parent 0585d1d commit 3c0692c

File tree

3 files changed

+67
-56
lines changed

3 files changed

+67
-56
lines changed

readthedocs/doc_builder/environments.py

+48-40
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,12 @@ def run_command_class(
463463

464464
if warn_only:
465465
log.warning(
466-
LOG_TEMPLATE.format(
467-
project=self.project.slug,
468-
version='latest',
469-
msg=msg,
470-
),
466+
LOG_TEMPLATE,
467+
{
468+
'project': self.project.slug,
469+
'version': 'latest',
470+
'msg': msg,
471+
}
471472
)
472473
else:
473474
raise BuildEnvironmentWarning(msg)
@@ -551,11 +552,12 @@ def __exit__(self, exc_type, exc_value, tb):
551552
ret = self.handle_exception(exc_type, exc_value, tb)
552553
self.update_build(BUILD_STATE_FINISHED)
553554
log.info(
554-
LOG_TEMPLATE.format(
555-
project=self.project.slug,
556-
version=self.version.slug,
557-
msg='Build finished',
558-
),
555+
LOG_TEMPLATE,
556+
{
557+
'project': self.project.slug,
558+
'version': self.version.slug,
559+
'msg': 'Build finished',
560+
}
559561
)
560562
return ret
561563

@@ -586,11 +588,12 @@ def handle_exception(self, exc_type, exc_value, _):
586588
self.failure = exc_value
587589

588590
log_level_function(
589-
LOG_TEMPLATE.format(
590-
project=self.project.slug,
591-
version=self.version.slug,
592-
msg=exc_value,
593-
),
591+
LOG_TEMPLATE,
592+
{
593+
'project': self.project.slug,
594+
'version': self.version.slug,
595+
'msg': exc_value,
596+
},
594597
exc_info=True,
595598
extra={
596599
'stack': True,
@@ -820,15 +823,16 @@ def __enter__(self):
820823
raise exc
821824
else:
822825
log.warning(
823-
LOG_TEMPLATE.format(
824-
project=self.project.slug,
825-
version=self.version.slug,
826-
msg=(
826+
LOG_TEMPLATE,
827+
{
828+
'project': self.project.slug,
829+
'version': self.version.slug,
830+
'msg': (
827831
'Removing stale container {}'.format(
828832
self.container_id,
829833
)
830834
),
831-
),
835+
}
832836
)
833837
client = self.get_client()
834838
client.remove_container(self.container_id)
@@ -874,11 +878,12 @@ def __exit__(self, exc_type, exc_value, tb):
874878
# request. These errors should not surface to the user.
875879
except (DockerAPIError, ConnectionError):
876880
log.exception(
877-
LOG_TEMPLATE.format(
878-
project=self.project.slug,
879-
version=self.version.slug,
880-
msg="Couldn't remove container",
881-
),
881+
LOG_TEMPLATE,
882+
{
883+
'project': self.project.slug,
884+
'version': self.version.slug,
885+
'msg': "Couldn't remove container",
886+
}
882887
)
883888
self.container = None
884889
except BuildEnvironmentError:
@@ -902,11 +907,12 @@ def get_client(self):
902907
return self.client
903908
except DockerException:
904909
log.exception(
905-
LOG_TEMPLATE.format(
906-
project=self.project.slug,
907-
version=self.version.slug,
908-
msg='Could not connect to Docker API',
909-
),
910+
LOG_TEMPLATE,
911+
{
912+
'project': self.project.slug,
913+
'version': self.version.slug,
914+
'msg': "Could not connect to Docker API",
915+
}
910916
)
911917
# We don't raise an error here mentioning Docker, that is a
912918
# technical detail that the user can't resolve on their own.
@@ -1024,14 +1030,15 @@ def create_container(self):
10241030
client.start(container=self.container_id)
10251031
except ConnectionError:
10261032
log.exception(
1027-
LOG_TEMPLATE.format(
1028-
project=self.project.slug,
1029-
version=self.version.slug,
1030-
msg=(
1033+
LOG_TEMPLATE,
1034+
{
1035+
'project': self.project.slug,
1036+
'version': self.version.slug,
1037+
'msg': (
10311038
'Could not connect to the Docker API, '
10321039
'make sure Docker is running'
10331040
),
1034-
),
1041+
}
10351042
)
10361043
# We don't raise an error here mentioning Docker, that is a
10371044
# technical detail that the user can't resolve on their own.
@@ -1043,10 +1050,11 @@ def create_container(self):
10431050
)
10441051
except DockerAPIError as e:
10451052
log.exception(
1046-
LOG_TEMPLATE.format(
1047-
project=self.project.slug,
1048-
version=self.version.slug,
1049-
msg=e.explanation,
1050-
),
1053+
LOG_TEMPLATE,
1054+
{
1055+
'project': self.project.slug,
1056+
'version': self.version.slug,
1057+
'msg': e.explanation,
1058+
}
10511059
)
10521060
raise BuildEnvironmentCreationFailed

readthedocs/doc_builder/python_environments.py

+18-15
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ def delete_existing_build_dir(self):
4444
)
4545
if os.path.exists(build_dir):
4646
log.info(
47-
LOG_TEMPLATE.format(
48-
project=self.project.slug,
49-
version=self.version.slug,
50-
msg='Removing existing build directory',
51-
),
47+
LOG_TEMPLATE,
48+
{
49+
'project': self.project.slug,
50+
'version': self.version.slug,
51+
'msg': 'Removing existing build directory',
52+
}
5253
)
5354
shutil.rmtree(build_dir)
5455

@@ -57,11 +58,12 @@ def delete_existing_venv_dir(self):
5758
# Handle deleting old venv dir
5859
if os.path.exists(venv_dir):
5960
log.info(
60-
LOG_TEMPLATE.format(
61-
project=self.project.slug,
62-
version=self.version.slug,
63-
msg='Removing existing venv directory',
64-
),
61+
LOG_TEMPLATE,
62+
{
63+
'project': self.project.slug,
64+
'version': self.version.slug,
65+
'msg': 'Removing existing venv directory',
66+
}
6567
)
6668
shutil.rmtree(venv_dir)
6769

@@ -413,11 +415,12 @@ def setup_base(self):
413415
if os.path.exists(version_path):
414416
# Re-create conda directory each time to keep fresh state
415417
log.info(
416-
LOG_TEMPLATE.format(
417-
project=self.project.slug,
418-
version=self.version.slug,
419-
msg='Removing existing conda directory',
420-
),
418+
LOG_TEMPLATE,
419+
{
420+
'project': self.project.slug,
421+
'version': self.version.slug,
422+
'msg': 'Removing existing conda directory',
423+
}
421424
)
422425
shutil.rmtree(version_path)
423426
self.build_env.run(

readthedocs/projects/constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
('other', 'Other'),
288288
)
289289

290-
LOG_TEMPLATE = '(Build) [{project}:{version}] {msg}'
290+
LOG_TEMPLATE = '(Build) [%(project)s:%(version)s] %(msg)s'
291291

292292
PROJECT_PK_REGEX = r'(?:[-\w]+)'
293293
PROJECT_SLUG_REGEX = r'(?:[-\w]+)'

0 commit comments

Comments
 (0)