documentation: Avoid potential unused variable code path.

These variables can be unset if the `os.path.exists` check fails.

That should be rare, since we've previously checked the files do
exist before getting here.
This commit is contained in:
Tim Abbott
2021-12-06 18:29:47 -08:00
parent 3319893545
commit 1c180a9f57

View File

@@ -145,6 +145,8 @@ class MarkdownDirectoryView(ApiURLView):
# The following is a somewhat hacky approach to extract titles from articles.
# Hack: `context["article"] has a leading `/`, so we use + to add directories.
article_path = os.path.join(settings.DEPLOY_ROOT, "templates") + context["article"]
endpoint_name = None
endpoint_method = None
if os.path.exists(article_path):
with open(article_path) as article_file:
first_line = article_file.readlines()[0]