Skip to content

Commit 89ed575

Browse files
committed
Rename sum to calc_sum to avoid name conflicts with built-in sum
1 parent ca93236 commit 89ed575

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/python_training_project/__main__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import click
99

10-
from python_training_project.calculate import sum
10+
from python_training_project.calculate import calc_sum
1111

1212
log = logging.getLogger(__name__)
1313

@@ -28,7 +28,7 @@ def cli():
2828
@click.argument("b", type=float)
2929
def cli_sum(a: float, b: float):
3030
"""Show the sum of two numbers on the console."""
31-
log.info("Sum of %f and %f is %f", a, b, sum(a, b))
31+
log.info("Sum of %f and %f is %f", a, b, calc_sum(a, b))
3232

3333

3434
if __name__ == "__main__":

src/python_training_project/calculate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55

6-
def sum(a: float, b: float) -> float:
6+
def calc_sum(a: float, b: float) -> float:
77
"""Calculate the sum of two numbers."""
88
return a + b
99

tests/test_calculate.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from python_training_project.calculate import sum
1+
from python_training_project.calculate import calc_sum
22

33

4-
def test_sum():
5-
assert sum(1, 1) == 2
6-
assert sum(2, 1) == 3
7-
assert sum(1, 2) == 3
4+
def test_calc_sum():
5+
assert calc_sum(1, 1) == 2
6+
assert calc_sum(2, 1) == 3
7+
assert calc_sum(1, 2) == 3
88

99

1010
def test_sum_negative():
11-
assert sum(1, -1) == 0
12-
assert sum(-1, 1) == 0
13-
assert sum(-1, -1) == -2
11+
assert calc_sum(1, -1) == 0
12+
assert calc_sum(-1, 1) == 0
13+
assert calc_sum(-1, -1) == -2

0 commit comments

Comments
 (0)