Skip to content

Commit

Permalink
style: improve code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Apr 26, 2020
1 parent df2c080 commit 0a4d8ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 6 additions & 5 deletions semantic_release/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

@LoggedFunction(logger)
def upload_to_pypi(
path: str = "dist",
skip_existing: bool = False,
path: str = "dist", skip_existing: bool = False,
):
"""Upload wheels to PyPI with Twine.
Expand All @@ -35,11 +34,13 @@ def upload_to_pypi(
username = os.environ.get("PYPI_USERNAME")
password = os.environ.get("PYPI_PASSWORD")
if not (username or password):
raise ImproperConfigurationError("Missing credentials for uploading to PyPI")
raise ImproperConfigurationError(
"Missing credentials for uploading to PyPI"
)
elif not token.startswith("pypi-"):
raise ImproperConfigurationError("PyPI token should begin with \"pypi-\"")
raise ImproperConfigurationError('PyPI token should begin with "pypi-"')
else:
username = '__token__'
username = "__token__"
password = token

run(
Expand Down
13 changes: 11 additions & 2 deletions tests/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

class PypiTests(TestCase):
@mock.patch("semantic_release.pypi.run")
@mock.patch.dict("os.environ", {"PYPI_USERNAME": "username", "PYPI_PASSWORD": "password"})
@mock.patch.dict(
"os.environ", {"PYPI_USERNAME": "username", "PYPI_PASSWORD": "password"}
)
def test_upload_with_password(self, mock_run):
upload_to_pypi()
self.assertEqual(
Expand All @@ -26,7 +28,14 @@ def test_upload_with_token(self, mock_run):
)

@mock.patch("semantic_release.pypi.run")
@mock.patch.dict("os.environ", {"PYPI_TOKEN": "pypi-x", "PYPI_USERNAME": "username", "PYPI_PASSWORD": "password"})
@mock.patch.dict(
"os.environ",
{
"PYPI_TOKEN": "pypi-x",
"PYPI_USERNAME": "username",
"PYPI_PASSWORD": "password",
},
)
def test_upload_prefers_token_over_password(self, mock_run):
upload_to_pypi()
self.assertEqual(
Expand Down

0 comments on commit 0a4d8ba

Please sign in to comment.