8000 Sourcery Starbot ⭐ refactored gkitg/edu_tmp by SourceryAI · Pull Request #1 · gkitg/edu_tmp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Sourcery Starbot ⭐ refactored gkitg/edu_tmp #1

10000 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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SourceryAI
Copy link

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 master branch, then run:

git fetch https://github.com/sourcery-ai-bot/edu_tmp master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines 14 to 26

# длинный способ
if year % 4 != 0:
print("Обычный")
elif year % 100 == 0:
if year % 400 == 0:
print("Високосный")
else:
print("Обычный")
if (
year % 4 == 0
and year % 100 == 0
and year % 400 == 0
or year % 4 == 0
and year % 100 != 0
):
print("Високосный")
else:
print("Високосный") No newline at end of file
print("Обычный")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 15-25 refactored with the following changes:

num = num // 10
num //= 10
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 17-17 refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

num = num // 10
num //= 10
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 14-14 refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

if n == 1:
return n
sum_n = n + sum_natural(n - 1)
return sum_n
return n if n == 1 else n + sum_natural(n - 1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function sum_natural refactored with the following changes:

if number < 10:
return number
return number % 10 + sum_digits(number // 10)
return number if number < 10 else number % 10 + sum_digits(number // 10)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function sum_digits refactored with the following changes:

Comment on lines -16 to +17
x = "".join([i for i in x])
y = "".join([i for i in y])
x = "".join(list(x))
y = "".join(list(y))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function hex_sum refactored with the following changes:

Comment on lines -24 to +25
x = "".join([i for i in x])
y = "".join([i for i in y])
x = "".join(list(x))
y = "".join(list(y))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function hex_mul refactored with the following changes:

Comment on lines -29 to +35
else:
r = deque()
while x > 15:
d = x % 16
r.appendleft(str(d) if d < 10 else self.hex_letters._fields[d-10])
x = x // 16
r.appendleft(str(x) if x < 10 else self.hex_letters._fields[x-10])
return list(r)
r = deque()
while x > 15:
d = x % 16
r.appendleft(str(d) if d < 10 else self.hex_letters._fields[d-10])
x = x // 16
r.appendleft(str(x) if x < 10 else self.hex_letters._fields[x-10])
return list(r)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function HexCalc.to_hex refactored with the following changes:

return sum([hex_number[j] * (16 ** i) for i, j in enumerate(num)])
return sum(hex_number[j] * (16 ** i) for i, j in enumerate(num))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function hex_to_decimal refactored with the following changes:

Comment on lines -21 to +25
for key in pi_func.keys():
for key, size in pi_func.items():
if num <= key:
size = pi_func[key]
break

array = [i for i in range(size)]
array = list(range(size))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function prime refactored with the following changes:

Comment on lines -7 to +9
for i in range(num):
for _ in range(num):
name = input('name = ')
spam = []
for j in range(1, 5):
spam.append(int(input(f'{j} = ')))
spam = [int(input(f'{j} = ')) for j in range(1, 5)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 7-11 refactored with the following changes:

num = num // 10
num //= 10
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 15-32 refactored with the following changes:

  • Replace assignment with augmented assignment [×2] (aug-assign)

orig_list = [random.randint(-100, 100) for i in range(10)]
orig_list = [random.randint(-100, 100) for _ in range(10)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 40-40 refactored with the following changes:

Comment on lines -11 to +40
if len(alist)>1:
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]

merge_sort(lefthalf)
merge_sort(righthalf)

i=0
j=0
k=0
while i<len(lefthalf) and j<len(righthalf):
if lefthalf[i]<righthalf[j]:
alist[k]=lefthalf[i]
i=i+1
else:
alist[k]=righthalf[j]
j=j+1
k=k+1

while i<len(lefthalf):
if len(alist) <= 1:
return
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]

merge_sort(lefthalf)
merge_sort(righthalf)

i=0
j=0
k=0
while i<len(lefthalf) and j<len(righthalf):
if lefthalf[i]<righthalf[j]:
alist[k]=lefthalf[i]
i=i+1
k=k+1

while j<len(righthalf):
i += 1
else:
alist[k]=righthalf[j]
j=j+1
k=k+1
j += 1
k=k+1

while i<len(lefthalf):
alist[k]=lefthalf[i]
i += 1
k=k+1

while j<len(righthalf):
alist[k]=righthalf[j]
j += 1
k=k+1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function merge_sort refactored with the following changes:

Comment on lines -43 to +44
alist = [random.random()*50 for i in range(n)]
alist = [random.random()*50 for _ in range(n)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 43-43 refactored with the following changes:

Comment on lines -11 to +15
if any(i.isupper() for i in data) and any(i.islower() for i in data) and any(i.isdigit() for i in data):
return True
else:
return False
return (
any(i.isupper() for i in data)
and any(i.islower() for i in data)
and any(i.isdigit() for i in data)
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function checkio refactored with the following changes:

Comment on lines -57 to +58
newlst=[]
for i in data:
if data.count(i)>1:
newlst.append(i)
return newlst
return [i for i in data if data.count(i)>1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function checkio refactored with the following changes:

Comment on lines -67 to +64
assert list(checkio([1, 2, 3, 4, 5])) == [], "2nd example"
assert not list(checkio([1, 2, 3, 4, 5])), "2nd example"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 67-67 refactored with the following changes:

segment = (((x1 - x2) ** 2) + ((y1 - y2) ** 2)) ** 0.5
return segment
return (((x1 - x2) ** 2) + ((y1 - y2) ** 2)) ** 0.5
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function length_segment refactored with the following changes:

Comment on lines -77 to +82
elif (line_a[0] == line_b[0] and (line_a[0] != line_c[0] or line_b[0] != line_c[0])):
elif line_a[0] == line_b[0]:
print("a || b")
print(0)
elif (line_a[0] == line_c[0] and (line_a[0] != line_b[0] or line_c[0] != line_b[0])):
elif line_a[0] == line_c[0]:
print("a || с")
print(0)
elif (line_b[0] == line_c[0] and (line_b[0] != line_a[0] or line_c[0] != line_a[0])):
elif line_b[0] == line_c[0]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0