Add pyupgrade pre-commit hook + modernize python code (#2611)

This commit is contained in:
Asher Foa
2025-06-10 14:52:38 -04:00
committed by GitHub
parent 272985f1bb
commit effd0c4911
18 changed files with 47 additions and 45 deletions

View File

@@ -255,7 +255,7 @@ class AsyncAWSClient:
return await client.deregister_task_definition(taskDefinition=task_definition)
class S3Uri(object):
class S3Uri:
# From: https://stackoverflow.com/questions/42641315/s3-urls-get-bucket-name-and-path
"""
>>> s = S3Uri("s3://bucket/hello/world")

View File

@@ -38,7 +38,7 @@ class LocalStorage(BaseStorage):
if not file_path.exists():
return []
try:
with open(file_path, "r") as f:
with open(file_path) as f:
return [line.strip() for line in f.readlines() if line.strip()]
except Exception:
return []

View File

@@ -211,7 +211,7 @@ class Block(BaseModel, abc.ABC):
return template.render(template_data)
@classmethod
def get_subclasses(cls) -> tuple[type["Block"], ...]:
def get_subclasses(cls) -> tuple[type[Block], ...]:
return tuple(cls.__subclasses__())
@staticmethod
@@ -2123,7 +2123,7 @@ class FileParserBlock(Block):
def validate_file_type(self, file_url_used: str, file_path: str) -> None:
if self.file_type == FileType.CSV:
try:
with open(file_path, "r") as file:
with open(file_path) as file:
csv.Sniffer().sniff(file.read(1024))
except csv.Error as e:
raise InvalidFileType(file_url=file_url_used, file_type=self.file_type, error=str(e))
@@ -2172,7 +2172,7 @@ class FileParserBlock(Block):
self.validate_file_type(self.file_url, file_path)
# Parse the file into a list of dictionaries where each dictionary represents a row in the file
parsed_data = []
with open(file_path, "r") as file:
with open(file_path) as file:
if self.file_type == FileType.CSV:
reader = csv.DictReader(file)
for row in reader: