Skip to content

Commit 7bfbc16

Browse files
authored
Merge pull request readthedocs#5662 from saadmk11/fix-lint-projects-app
pylint fix for readthedocs.projects
2 parents c6d052a + ee8e938 commit 7bfbc16

File tree

3 files changed

+78
-63
lines changed

3 files changed

+78
-63
lines changed

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]+)'

readthedocs/projects/models.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -924,18 +924,22 @@ def update_stable_version(self):
924924
)
925925
if identifier_updated and current_stable.machine:
926926
log.info(
927-
'Update stable version: {project}:{version}'.format(
928-
project=self.slug,
929-
version=new_stable.identifier,
930-
),
927+
'Update stable version: %(project)s:%(version)s',
928+
{
929+
'project': self.slug,
930+
'version': new_stable.identifier,
931+
}
931932
)
932933
current_stable.identifier = new_stable.identifier
933934
current_stable.save()
934935
return new_stable
935936
else:
936937
log.info(
937-
'Creating new stable version: {project}:{version}'
938-
.format(project=self.slug, version=new_stable.identifier),
938+
'Creating new stable version: %(project)s:%(version)s',
939+
{
940+
'project': self.slug,
941+
'version': new_stable.identifier,
942+
}
939943
)
940944
current_stable = self.versions.create_stable(
941945
type=new_stable.type,
@@ -1161,7 +1165,7 @@ class HTMLFile(ImportedFile):
11611165
This tracks only the HTML files for indexing to search.
11621166
"""
11631167

1164-
class Meta(object):
1168+
class Meta:
11651169
proxy = True
11661170

11671171
objects = HTMLFileManager()

readthedocs/projects/tasks.py

+66-55
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,12 @@ def sync_repo(self):
144144
identifier=self.version.identifier,
145145
)
146146
log.info(
147-
LOG_TEMPLATE.format(
148-
project=self.project.slug,
149-
version=self.version.slug,
150-
msg=msg,
151-
),
147+
LOG_TEMPLATE,
148+
{
149+
'project': self.project.slug,
150+
'version': self.version.slug,
151+
'msg': msg,
152+
}
152153
)
153154
version_repo = self.get_vcs_repo()
154155
version_repo.update()
@@ -484,11 +485,12 @@ def run_setup(self, record=True):
484485
self.setup_env.failure,
485486
)
486487
log.info(
487-
LOG_TEMPLATE.format(
488-
project=self.project.slug,
489-
version=self.version.slug,
490-
msg=msg,
491-
),
488+
LOG_TEMPLATE,
489+
{
490+
'project': self.project.slug,
491+
'version': self.version.slug,
492+
'msg': msg,
493+
}
492494
)
493495

494496
# Send notification to users only if the build didn't fail because
@@ -545,11 +547,12 @@ def run_build(self, docker, record):
545547
python_env_cls = Virtualenv
546548
if self.config.conda is not None:
547549
log.info(
548-
LOG_TEMPLATE.format(
549-
project=self.project.slug,
550-
version=self.version.slug,
551-
msg='Using conda',
552-
),
550+
LOG_TEMPLATE,
551+
{
552+
'project': self.project.slug,
553+
'version': self.version.slug,
554+
'msg': 'Using conda',
555+
}
553556
)
554557
python_env_cls = Conda
555558
self.python_env = python_env_cls(
@@ -624,11 +627,12 @@ def setup_vcs(self):
624627
self.setup_env.update_build(state=BUILD_STATE_CLONING)
625628

626629
log.info(
627-
LOG_TEMPLATE.format(
628-
project=self.project.slug,
629-
version=self.version.slug,
630-
msg='Updating docs from VCS',
631-
),
630+
LOG_TEMPLATE,
631+
{
632+
'project': self.project.slug,
633+
'version': self.version.slug,
634+
'msg': 'Updating docs from VCS',
635+
}
632636
)
633637
try:
634638
self.sync_repo()
@@ -1028,11 +1032,12 @@ def move_files(
10281032
storage.delete(storage_path)
10291033

10301034
log.debug(
1031-
LOG_TEMPLATE.format(
1032-
project=version.project.slug,
1033-
version=version.slug,
1034-
msg='Moving files',
1035-
),
1035+
LOG_TEMPLATE,
1036+
{
1037+
'project': version.project.slug,
1038+
'version': version.slug,
1039+
'msg': 'Moving files',
1040+
}
10361041
)
10371042

10381043
if html:
@@ -1178,24 +1183,26 @@ def fileify(version_pk, commit):
11781183

11791184
if not commit:
11801185
log.warning(
1181-
LOG_TEMPLATE.format(
1182-
project=project.slug,
1183-
version=version.slug,
1184-
msg=(
1186+
LOG_TEMPLATE,
1187+
{
1188+
'project': project.slug,
1189+
'version': version.slug,
1190+
'msg': (
11851191
'Search index not being built because no commit information'
11861192
),
1187-
),
1193+
}
11881194
)
11891195
return
11901196

11911197
path = project.rtd_build_path(version.slug)
11921198
if path:
11931199
log.info(
1194-
LOG_TEMPLATE.format(
1195-
project=version.project.slug,
1196-
version=version.slug,
1197-
msg='Creating ImportedFiles',
1198-
),
1200+
LOG_TEMPLATE,
1201+
{
1202+
'project': version.project.slug,
1203+
'version': version.slug,
1204+
'msg': 'Creating ImportedFiles',
1205+
}
11991206
)
12001207
try:
12011208
_manage_imported_files(version, path, commit)
@@ -1414,11 +1421,12 @@ def email_notification(version, build, email):
14141421
:param email: Email recipient address
14151422
"""
14161423
log.debug(
1417-
LOG_TEMPLATE.format(
1418-
project=version.project.slug,
1419-
version=version.slug,
1420-
msg='sending email to: %s' % email,
1421-
),
1424+
LOG_TEMPLATE,
1425+
{
1426+
'project': version.project.slug,
1427+
'version': version.slug,
1428+
'msg': 'sending email to: %s' % email,
1429+
}
14221430
)
14231431

14241432
# We send only what we need from the Django model objects here to avoid
@@ -1482,11 +1490,12 @@ def webhook_notification(version, build, hook_url):
14821490
},
14831491
})
14841492
log.debug(
1485-
LOG_TEMPLATE.format(
1486-
project=project.slug,
1487-
version='',
1488-
msg='sending notification to: %s' % hook_url,
1489-
),
1493+
LOG_TEMPLATE,
1494+
{
1495+
'project': project.slug,
1496+
'version': '',
1497+
'msg': 'sending notification to: %s' % hook_url,
1498+
}
14901499
)
14911500
try:
14921501
requests.post(hook_url, data=data)
@@ -1515,11 +1524,12 @@ def update_static_metadata(project_pk, path=None):
15151524
path = project.static_metadata_path()
15161525

15171526
log.info(
1518-
LOG_TEMPLATE.format(
1519-
project=project.slug,
1520-
version='',
1521-
msg='Updating static metadata',
1522-
),
1527+
LOG_TEMPLATE,
1528+
{
1529+
'project': project.slug,
1530+
'version': '',
1531+
'msg': 'Updating static metadata',
1532+
}
15231533
)
15241534
translations = [trans.language for trans in project.translations.all()]
15251535
languages = set(translations)
@@ -1538,11 +1548,12 @@ def update_static_metadata(project_pk, path=None):
15381548
fh.close()
15391549
except (AttributeError, IOError) as e:
15401550
log.debug(
1541-
LOG_TEMPLATE.format(
1542-
project=project.slug,
1543-
version='',
1544-
msg='Cannot write to metadata.json: {}'.format(e),
1545-
),
1551+
LOG_TEMPLATE,
1552+
{
1553+
'project': project.slug,
1554+
'version': '',
1555+
'msg': 'Cannot write to metadata.json: {}'.format(e),
1556+
}
15461557
)
15471558

15481559

0 commit comments

Comments
 (0)