Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply flake8-bugbear rule #1043

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions twine/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def from_filename(cls, filename: str, comment: Optional[str]) -> "PackageFile":
if filename.endswith(ext):
try:
meta = DIST_TYPES[dtype](filename)
except EOFError:
except EOFError as exc:
raise exceptions.InvalidDistribution(
"Invalid distribution file: '%s'" % os.path.basename(filename)
)
) from exc
else:
break
else:
Expand Down Expand Up @@ -221,21 +221,21 @@ def run_gpg(cls, gpg_args: Tuple[str, ...]) -> None:
try:
subprocess.check_call(gpg_args)
return
except FileNotFoundError:
except FileNotFoundError as exc:
if gpg_args[0] != "gpg":
raise exceptions.InvalidSigningExecutable(
f"{gpg_args[0]} executable not available."
)
) from exc

logger.warning("gpg executable not available. Attempting fallback to gpg2.")
try:
subprocess.check_call(("gpg2",) + gpg_args[1:])
except FileNotFoundError:
except FileNotFoundError as exc:
raise exceptions.InvalidSigningExecutable(
"'gpg' or 'gpg2' executables not available.\n"
"Try installing one of these or specifying an executable "
"with the --sign-with flag."
)
) from exc


class Hexdigest(NamedTuple):
Expand Down
8 changes: 4 additions & 4 deletions twine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _validate_repository_url(repository_url: str) -> None:
except rfc3986.exceptions.RFC3986Exception as exc:
raise exceptions.UnreachableRepositoryURLDetected(
f"Invalid repository URL: {exc.args[0]}."
)
) from exc


def get_repository_from_config(
Expand All @@ -135,12 +135,12 @@ def get_repository_from_config(
try:
config = get_config(config_file)[repository]
except OSError as exc:
raise exceptions.InvalidConfiguration(str(exc))
except KeyError:
raise exceptions.InvalidConfiguration(str(exc)) from exc
except KeyError as exc:
raise exceptions.InvalidConfiguration(
f"Missing '{repository}' section from {config_file}.\n"
f"More info: https://packaging.python.org/specifications/pypirc/ "
)
) from exc

config["repository"] = normalize_repository_url(cast(str, config["repository"]))
return config
Expand Down