Skip to content

Commit

Permalink
Linting, formatting, typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikram Jayanthi committed Jun 8, 2020
1 parent 8d05487 commit d51d02f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os

import pretend
import pytest
Expand Down
2 changes: 1 addition & 1 deletion twine/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def upload(upload_settings: settings.Settings, dists: List[str]) -> None:
print(f"Uploading distributions to {repository_url}")
if upload_settings.verbose:
for dist_to_upload in uploads:
#If the file size is <.1 MB we display in KB
# If the file size is <.1 MB we display in KB
file_size, size_unit = utils.get_file_size(dist_to_upload)
print(f" {dist_to_upload} ({file_size} {size_unit})")
print("\n")
Expand Down
12 changes: 7 additions & 5 deletions twine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from typing import Dict
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import Union
from urllib.parse import urlparse
from urllib.parse import urlunparse
Expand All @@ -31,6 +32,7 @@
import rfc3986

from twine import exceptions

# Shim for input to allow testing.
input_func = input

Expand Down Expand Up @@ -158,14 +160,14 @@ def normalize_repository_url(url: str) -> str:
return urlunparse(parsed)


def get_file_size(filepath : str) -> (float, str):
"""Calculates and returns the file size and unit"""
#If the file size is <.1 MB we display in KB
def get_file_size(filepath: str) -> Tuple[float, str]:
"""Return the file size and unit of size following PyPI's file size format."""
# If the file size is <.1 MB we display in KB
size_unit = "MB"
file_size = round(os.path.getsize(filepath)/(1024 * 1024), 1)
file_size = round(os.path.getsize(filepath) / (1024 * 1024), 1)
if not file_size:
size_unit = "KB"
file_size = round(os.path.getsize(filepath)/(1024), 1)
file_size = round(os.path.getsize(filepath) / (1024), 1)
return file_size, size_unit


Expand Down

0 comments on commit d51d02f

Please sign in to comment.