1
0
Fork 0
mirror of synced 2024-09-28 15:22:16 +12:00

B907 Cleanup/updates

Cleanup some double quoted locations based on bugbear B907 and add same formatting to some other locations the emphasis may be helpful.
This commit is contained in:
OMEGARAZER 2023-02-18 15:58:05 -05:00
parent 5cf2c81b0c
commit 5c57de7c7d
No known key found for this signature in database
GPG key ID: D89925310D306E35
7 changed files with 11 additions and 11 deletions

View file

@ -182,7 +182,7 @@ def cli_completion(shell: str, uninstall: bool):
Completion(shell).uninstall() Completion(shell).uninstall()
return return
if shell not in ("all", "bash", "fish", "zsh"): if shell not in ("all", "bash", "fish", "zsh"):
print(f"{shell} is not a valid option.") print(f"{shell!r} is not a valid option.")
print("Options: all, bash, fish, zsh") print("Options: all, bash, fish, zsh")
return return
if click.confirm(f"Would you like to install {shell} completions for BDFR"): if click.confirm(f"Would you like to install {shell} completions for BDFR"):

View file

@ -94,7 +94,7 @@ class Archiver(RedditConnector):
elif self.args.format == "yaml": elif self.args.format == "yaml":
self._write_entry_yaml(archive_entry) self._write_entry_yaml(archive_entry)
else: else:
raise ArchiverError(f"Unknown format {self.args.format} given") raise ArchiverError(f"Unknown format {self.args.format!r} given")
logger.info(f"Record for entry item {praw_item.id} written to disk") logger.info(f"Record for entry item {praw_item.id} written to disk")
def _write_entry_json(self, entry: BaseArchiveEntry): def _write_entry_json(self, entry: BaseArchiveEntry):

View file

@ -63,7 +63,7 @@ class Configuration(Namespace):
self.parse_yaml_options(context.params["opts"]) self.parse_yaml_options(context.params["opts"])
for arg_key in context.params.keys(): for arg_key in context.params.keys():
if not hasattr(self, arg_key): if not hasattr(self, arg_key):
logger.warning(f"Ignoring an unknown CLI argument: {arg_key}") logger.warning(f"Ignoring an unknown CLI argument: {arg_key!r}")
continue continue
val = context.params[arg_key] val = context.params[arg_key]
if val is None or val == (): if val is None or val == ():
@ -84,6 +84,6 @@ class Configuration(Namespace):
return return
for arg_key, val in opts.items(): for arg_key, val in opts.items():
if not hasattr(self, arg_key): if not hasattr(self, arg_key):
logger.warning(f"Ignoring an unknown YAML argument: {arg_key}") logger.warning(f"Ignoring an unknown YAML argument: {arg_key!r}")
continue continue
setattr(self, arg_key, val) setattr(self, arg_key, val)

View file

@ -115,7 +115,7 @@ class RedditConnector(metaclass=ABCMeta):
self.args.filename_restriction_scheme = self.cfg_parser.get( self.args.filename_restriction_scheme = self.cfg_parser.get(
"DEFAULT", "filename_restriction_scheme", fallback=None "DEFAULT", "filename_restriction_scheme", fallback=None
) )
logger.debug(f"Setting filename restriction scheme to '{self.args.filename_restriction_scheme}'") logger.debug(f"Setting filename restriction scheme to {self.args.filename_restriction_scheme!r}")
# Update config on disk # Update config on disk
with Path(self.config_location).open(mode="w") as file: with Path(self.config_location).open(mode="w") as file:
self.cfg_parser.write(file) self.cfg_parser.write(file)
@ -239,7 +239,7 @@ class RedditConnector(metaclass=ABCMeta):
pattern = re.compile(r"^(?:https://www\.reddit\.com/)?(?:r/)?(.*?)/?$") pattern = re.compile(r"^(?:https://www\.reddit\.com/)?(?:r/)?(.*?)/?$")
match = re.match(pattern, subreddit) match = re.match(pattern, subreddit)
if not match: if not match:
raise errors.BulkDownloaderException(f"Could not find subreddit name in string {subreddit}") raise errors.BulkDownloaderException(f"Could not find subreddit name in string {subreddit!r}")
return match.group(1) return match.group(1)
@staticmethod @staticmethod
@ -285,7 +285,7 @@ class RedditConnector(metaclass=ABCMeta):
) )
) )
logger.debug( logger.debug(
f'Added submissions from subreddit {reddit} with the search term "{self.args.search}"' f"Added submissions from subreddit {reddit} with the search term {self.args.search!r}"
) )
else: else:
out.append(self.create_filtered_listing_generator(reddit)) out.append(self.create_filtered_listing_generator(reddit))

View file

@ -35,7 +35,7 @@ class DownloadFilter:
combined_extensions = "|".join(self.excluded_extensions) combined_extensions = "|".join(self.excluded_extensions)
pattern = re.compile(rf".*({combined_extensions})$") pattern = re.compile(rf".*({combined_extensions})$")
if re.match(pattern, resource_extension): if re.match(pattern, resource_extension):
logger.log(9, f'Url "{resource_extension}" matched with "{pattern}"') logger.log(9, f"Url {resource_extension!r} matched with {pattern!r}")
return False return False
else: else:
return True return True
@ -46,7 +46,7 @@ class DownloadFilter:
combined_domains = "|".join(self.excluded_domains) combined_domains = "|".join(self.excluded_domains)
pattern = re.compile(rf"https?://.*({combined_domains}).*") pattern = re.compile(rf"https?://.*({combined_domains}).*")
if re.match(pattern, url): if re.match(pattern, url):
logger.log(9, f'Url "{url}" matched with "{pattern}"') logger.log(9, f"Url {url!r} matched with {pattern!r}")
return False return False
else: else:
return True return True

View file

@ -37,7 +37,7 @@ class FileNameFormatter:
restriction_scheme: Optional[str] = None, restriction_scheme: Optional[str] = None,
): ):
if not self.validate_string(file_format_string): if not self.validate_string(file_format_string):
raise BulkDownloaderException(f'"{file_format_string}" is not a valid format string') raise BulkDownloaderException(f"{file_format_string!r} is not a valid format string")
self.file_format_string = file_format_string self.file_format_string = file_format_string
self.directory_format_string: list[str] = directory_format_string.split("/") self.directory_format_string: list[str] = directory_format_string.split("/")
self.time_format_string = time_format_string self.time_format_string = time_format_string

View file

@ -33,7 +33,7 @@ class OAuth2Authenticator:
known_scopes.append("*") known_scopes.append("*")
for scope in wanted_scopes: for scope in wanted_scopes:
if scope not in known_scopes: if scope not in known_scopes:
raise BulkDownloaderException(f"Scope {scope} is not known to reddit") raise BulkDownloaderException(f"Scope {scope!r} is not known to reddit")
@staticmethod @staticmethod
def split_scopes(scopes: str) -> set[str]: def split_scopes(scopes: str) -> set[str]: