-
Notifications
You must be signed in to change notification settings - Fork 2
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
Sourcery Starbot ⭐ refactored NicolasFlandrois/Stardate #2
base: main
Are you sure you want to change the base?
Conversation
def ask_integer(message: str, range, error_message: str = ""): | ||
def ask_integer(self, range, error_message: str = ""): | ||
""" | ||
This function's purpose is to ask and verify an Integer. | ||
""" | ||
var = None | ||
while True: | ||
try: | ||
var = int(input(message)) | ||
var = int(input(self)) | ||
if var in range: | ||
return var | ||
raise | ||
|
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 Compute.ask_integer
refactored with the following changes:
- The first argument to instance methods should be
self
(instance-method-first-arg-name
) - Remove unreachable code (
remove-unreachable-code
)
def leapyr(year: int): | ||
def leapyr(self): | ||
"""" | ||
This function defines if the year is | ||
a Leap year (366 days) | ||
or a Normal year (365 days). | ||
Then it will to the variable n the value of 366 or 365, accordingly. | ||
""" | ||
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0): | ||
n = 366 | ||
# print("The year is a Leap year.\n") | ||
|
||
else: | ||
n = 365 | ||
# print("The year is a normal year.\n") | ||
|
||
return n | ||
return 366 if self % 400 == 0 or self % 4 == 0 and self % 100 != 0 else 365 |
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 Compute.leapyr
refactored with the following changes:
- The first argument to instance methods should be
self
(instance-method-first-arg-name
) - Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
This removes the following comments ( why? ):
# print("The year is a Leap year.\n")
# print("The year is a normal year.\n")
def sdconvert(t): | ||
def sdconvert(self): |
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 Compute.sdconvert
refactored with the following changes:
- The first argument to instance methods should be
self
(instance-method-first-arg-name
)
def sdtranslate(sd): | ||
def sdtranslate(self): |
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 Compute.sdtranslate
refactored with the following changes:
- The first argument to instance methods should be
self
(instance-method-first-arg-name
) - Move assignment closer to its usage within a block [×2] (
move-assign-in-block
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
) - Merge append into list declaration [×2] (
merge-list-append
)
def menu(convert, translate): | ||
def menu(self, translate): |
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 View.menu
refactored with the following changes:
- The first argument to instance methods should be
self
(instance-method-first-arg-name
) - Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
dlist = [] | ||
dlist.append(Compute.ask_integer("Earth Year? (YYYY format) ", | ||
range(-10000000, 10000000))) | ||
dlist = [ | ||
Compute.ask_integer( | ||
"Earth Year? (YYYY format) ", range(-10000000, 10000000) | ||
) | ||
] |
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 View.ask_date
refactored with the following changes:
- Merge append into list declaration (
merge-list-append
)
def show_date(earthdate): | ||
def show_date(self): | ||
""" | ||
Displays a date object, in a User Experience readable format. | ||
""" | ||
return earthdate()[1] | ||
return self()[1] |
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 View.show_date
refactored with the following changes:
- The first argument to instance methods should be
self
(instance-method-first-arg-name
)
def show_stardate(stardate, date): | ||
def show_stardate(self, date): | ||
""" | ||
Displays Date's Stardate. | ||
""" | ||
print("Earthdate : ", date) | ||
print("\nStardate : ", stardate) | ||
print("\nStardate : ", self) |
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 View.show_stardate
refactored with the following changes:
- The first argument to instance methods should be
self
(instance-method-first-arg-name
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
main
branch, then run: