This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
forked from sesh/piprot
-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery Starbot ⭐ refactored falcorocks/piprot #1
Open
SourceryAI
wants to merge
1
commit into
falcorocks:master
Choose a base branch
from
SourceryAI:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,12 +171,11 @@ def get_version_and_release_date(requirement, version=None, | |
|
||
response = response.json() | ||
except requests.HTTPError: | ||
if version: | ||
if verbose: | ||
if verbose: | ||
if version: | ||
print('{} ({}) isn\'t available on PyPI ' | ||
'anymore!'.format(requirement, version)) | ||
else: | ||
if verbose: | ||
else: | ||
print('{} isn\'t on PyPI. Check that the project ' | ||
'still exists!'.format(requirement)) | ||
return None, None | ||
|
@@ -195,25 +194,25 @@ def get_version_and_release_date(requirement, version=None, | |
else: | ||
version = response['info'].get('stable_version') | ||
|
||
if not version: | ||
if not version: | ||
versions = { | ||
v: parse_version(v) for v in response['releases'].keys() | ||
if not parse_version(v).is_prerelease() | ||
} | ||
|
||
# if we still don't have a version, let's pick up a prerelease one | ||
if not versions: | ||
versions = { | ||
v: parse_version(v) for v in response['releases'].keys() | ||
if not parse_version(v).is_prerelease() | ||
} | ||
|
||
# if we still don't have a version, let's pick up a prerelease one | ||
if not versions: | ||
versions = { | ||
v: parse_version(v) for v in response['releases'].keys() | ||
} | ||
|
||
if versions: | ||
version = max(versions.items(), key=operator.itemgetter(1))[0] | ||
release_date = ( | ||
response['releases'][str(version)][0]['upload_time'] | ||
) | ||
else: | ||
return None, None | ||
if versions: | ||
version = max(versions.items(), key=operator.itemgetter(1))[0] | ||
release_date = ( | ||
response['releases'][str(version)][0]['upload_time'] | ||
) | ||
else: | ||
return None, None | ||
|
||
return version, datetime.fromtimestamp(time.mktime( | ||
time.strptime(release_date, '%Y-%m-%dT%H:%M:%S') | ||
|
@@ -306,7 +305,7 @@ def main( | |
|
||
if latest_release_date and specified_release_date: | ||
time_delta = (latest_release_date - specified_release_date).days | ||
total_time_delta = total_time_delta + time_delta | ||
total_time_delta += time_delta | ||
Comment on lines
-309
to
+308
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
max_outdated_time = max(time_delta, max_outdated_time) | ||
|
||
if verbose: | ||
|
@@ -347,7 +346,7 @@ def main( | |
"days out of date which is more than the allowed" | ||
"{} days.".format(verbatim_str, max_outdated_time, delay)) | ||
sys.exit(1) | ||
elif delay is not None and max_outdated_time <= int(delay): | ||
elif delay is not None: | ||
print("{}All of your dependencies are at most {} " | ||
"days out of date.".format(verbatim_str, delay)) | ||
else: | ||
|
@@ -433,11 +432,8 @@ def piprot(): | |
sys.exit('--verbatim only allowed for single requirements files') | ||
|
||
verbose = True | ||
if cli_args.quiet: | ||
verbose = False | ||
elif cli_args.verbatim: | ||
if cli_args.quiet or cli_args.verbatim: | ||
verbose = False | ||
|
||
Comment on lines
-436
to
-440
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
# call the main function to kick off the real work | ||
main(req_files=cli_args.file, verbose=verbose, outdated=cli_args.outdated, | ||
latest=cli_args.latest, verbatim=cli_args.verbatim, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,12 +42,12 @@ def get_default_branch(repo): | |
"""returns the name of the default branch of the repo""" | ||
url = "{}/repos/{}".format(GITHUB_API_BASE, repo) | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
api_response = json.loads(response.text) | ||
return api_response['default_branch'] | ||
else: | ||
if response.status_code != 200: | ||
return 'master' | ||
|
||
api_response = json.loads(response.text) | ||
return api_response['default_branch'] | ||
Comment on lines
-45
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def get_requirements_file_from_url(url): | ||
"""fetches the requiremets from the url""" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
get_version_and_release_date
refactored with the following changes:hoist-if-from-if
)hoist-statement-from-if
)