Skip to content

Commit

Permalink
Merge pull request #976 from NASA-IMPACT/975-fix-flake8-problems-to-g…
Browse files Browse the repository at this point in the history
…et-pre-commit-passing

Fix fake flake8 issues
  • Loading branch information
code-geek authored Aug 26, 2024
2 parents ed30d45 + 9cc9acd commit 7dd0b97
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
# ------------------------
STATICFILES_STORAGE = "sde_indexing_helper.utils.storages.StaticRootS3Boto3Storage"
COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy"
STATIC_URL = f"https://{aws_s3_domain}/static/"
STATIC_URL = f"https://{aws_s3_domain}/static/" # noqa: E231
# MEDIA
# ------------------------------------------------------------------------------
DEFAULT_FILE_STORAGE = "sde_indexing_helper.utils.storages.MediaRootS3Boto3Storage"
MEDIA_URL = f"https://{aws_s3_domain}/media/"
MEDIA_URL = f"https://{aws_s3_domain}/media/" # noqa: E231

# EMAIL
# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config_generation/db_to_xml_file_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def update_or_add_element_value(
parent_element = xml_root if not parent_element_name else xml_root.find(parent_element_name)

if parent_element is None:
raise ValueError(f"Parent element '{parent_element_name}' not found in XML.")
raise ValueError(f"Parent element '{parent_element_name}' not found in XML.") # noqa: E713

existing_element = parent_element.find(element_name)
if not add_duplicate and existing_element:
Expand Down
2 changes: 1 addition & 1 deletion feedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def format_notification_message(self):
Returns a formatted notification message containing details from this Feedback instance.
"""
notification_message = (
f"<!here> New Feedback Received : \n"
f"<!here> New Feedback Received : \n" # noqa: E203
f"Name: {self.name}\n"
f"Email: {self.email}\n"
f"Subject: {self.subject}\n"
Expand Down
6 changes: 4 additions & 2 deletions scraper/url_grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
output_file.write(f"<h1>{BASE_URL}</h1>\n")
output_file.write("<ul>\n")
for key, value in my_dict.items():
output_file.write(f'<li><a href="{PROTOCOL}://{BASE_URL}{key}" target=_blank>{key}</a>\n')
output_file.write(f'<li><a href="{PROTOCOL}://{BASE_URL}{key}" target=_blank>{key}</a>\n') # noqa: E231
output_file.write("<ul>\n")
for item in value:
output_file.write(f'<li><a href="{PROTOCOL}://{BASE_URL}{key}/{item}" target=_blank>{item}</a></li>\n')
output_file.write(
f'<li><a href="{PROTOCOL}://{BASE_URL}{key}/{item}" target=_blank>{item}</a></li>\n' # noqa: E231
)
output_file.write("</ul>\n")
output_file.write("</li>\n")
output_file.write("</ul>\n")
3 changes: 2 additions & 1 deletion scripts/ej/create_ej_dump.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
inferences are supplied by the classification model. the contact point is Bishwas
cmr is supplied by running https://github.com/NASA-IMPACT/llm-app-EJ-classifier/blob/develop/scripts/data_processing/download_cmr.py
cmr is supplied by running
github.com/NASA-IMPACT/llm-app-EJ-classifier/blob/develop/scripts/data_processing/download_cmr.py
move to the serve like this: scp ej_dump_20240814_143036.json sde:/home/ec2-user/sde_indexing_helper/backups/
"""

Expand Down
4 changes: 2 additions & 2 deletions scripts/find_redirects_solar_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def csv_to_dict_list(file_path):
scraped_title = soup.find("title").text.strip() if soup.find("title") else ""
except (AssertionError, Exception) as parse_error:
scraped_title = ""
print(f"Error parsing URL {url_info['url']}: {parse_error}")
print(f"Error parsing URL {url_info['url']}: {parse_error}") # noqa: F821
except requests.RequestException as e:
print(f"Error fetching URL {url_info['url']}: {e}")
print(f"Error fetching URL {url_info['url']}: {e}") # noqa: F821
response_url = ""
scraped_title = ""

Expand Down
3 changes: 2 additions & 1 deletion scripts/quality_and_indexing/restore_deleted_files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
you need to run this script in the root of the repository that from which the file was deleted, in this case the root of the sinequa_configs repository.
you need to run this script in the root of the repository that from which the file was deleted,
in this case the root of the sinequa_configs repository.
"""

import subprocess
Expand Down
2 changes: 1 addition & 1 deletion sde_collections/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def export_as_csv(self, request, queryset):
field_names = [field.name for field in meta.fields]

response = HttpResponse(content_type="text/csv")
response["Content-Disposition"] = f"attachment; filename={meta}.csv"
response["Content-Disposition"] = f"attachment; filename={meta}.csv" # noqa: E702
writer = csv.writer(response)

writer.writerow(field_names)
Expand Down
12 changes: 5 additions & 7 deletions sde_collections/models/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import requests
from django.contrib.auth import get_user_model
from django.db import models
from django.db.models import Q
from django.db.models.signals import post_save
from django.dispatch import receiver
from model_utils import FieldTracker
Expand Down Expand Up @@ -130,7 +129,7 @@ def tree_root(self) -> str:

@property
def server_url_secret_prod(self) -> str:
base_url = "https://sciencediscoveryengine.nasa.gov"
base_url = "https://sciencediscoveryengine.nasa.gov" # noqa: E231
payload = {
"name": "secret-prod",
"scope": "All",
Expand All @@ -144,7 +143,7 @@ def server_url_secret_prod(self) -> str:

@property
def server_url_prod(self) -> str:
base_url = "https://sciencediscoveryengine.nasa.gov"
base_url = "https://sciencediscoveryengine.nasa.gov" # noqa: E231
payload = {
"name": "query-smd-primary",
"scope": "All",
Expand Down Expand Up @@ -371,13 +370,12 @@ def candidate_urls_count(self) -> int:

@property
def sinequa_configuration(self) -> str:
return (
f"https://github.com/NASA-IMPACT/sde-backend/blob/production/sources/SDE/{self.config_folder}/default.xml"
)
URL = f"https://github.com/NASA-IMPACT/sde-backend/blob/production/sources/SDE/{self.config_folder}/default.xml" # noqa: E231, E501
return URL

@property
def github_issue_link(self) -> str:
return f"https://github.com/NASA-IMPACT/sde-project/issues/{self.github_issue_number}"
return f"https://github.com/NASA-IMPACT/sde-project/issues/{self.github_issue_number}" # noqa: E231

@classmethod
def _fetch_json_results(cls, url):
Expand Down
2 changes: 1 addition & 1 deletion sde_collections/models/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def validate_title_pattern(title_pattern_string):

if element_type == "xpath":
if not is_valid_xpath(element_value):
raise ValidationError(f"'xpath:{element_value}' is not a valid xpath.")
raise ValidationError(f"'xpath:{element_value}' is not a valid xpath.") # noqa: E231
elif element_type == "brace":
try:
is_valid_fstring(element_value)
Expand Down
4 changes: 2 additions & 2 deletions sde_collections/utils/health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ def create_exclude_pattern_report(match_pattern, url):

# check with http://
if match_pattern.find("http://") == -1:
url = f"http://{match_pattern}"
url = f"http://{match_pattern}" # noqa: E231
if url in candidate_urls_sinequa:
exclude_pattern_report.append(create_exclude_pattern_report(match_pattern, url))

if match_pattern.find("https://") == -1:
url = f"https://{match_pattern}"
url = f"https://{match_pattern}" # noqa: E231
if url in candidate_urls_sinequa:
exclude_pattern_report.append(create_exclude_pattern_report(match_pattern, url))
else:
Expand Down
4 changes: 2 additions & 2 deletions sde_collections/utils/slack_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
def format_slack_message(name, details, collection_id):
message_template = details["message"]
tags = " ".join([f"<{user}>" for user in details["tags"]])
link = f"https://sde-indexing-helper.nasa-impact.net/{collection_id}/"
link = f"https://sde-indexing-helper.nasa-impact.net/{collection_id}/" # noqa: E231
linked_name = f"<{link}|{name}>"
return tags + " " + message_template.format(name=linked_name)

Expand All @@ -101,5 +101,5 @@ def send_slack_message(message):
response = requests.post(webhook_url, json=payload)
if response.status_code != 200:
raise ValueError(
f"Request to Slack returned an error {response.status_code}, the response is:\n{response.text}"
f"Request to Slack returned an error {response.status_code}, the response is:\n{response.text}" # noqa: E231, E501
)
2 changes: 1 addition & 1 deletion sde_collections/utils/title_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def is_valid_fstring(pattern: str) -> bool:
if node.value.id not in context:
variables_allowed = ", ".join([key for key in context.keys()])
raise ValueError(
f"Variable '{node.value.id}' not allowed in f-string pattern."
f"Variable '{node.value.id}' not allowed in f-string pattern." # noqa: E713
f" Allowed variables are: {variables_allowed}"
)

Expand Down

0 comments on commit 7dd0b97

Please sign in to comment.