Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ae8f089
Commit pyproject.toml
hayat01sh1da Apr 11, 2026
290b1c1
Introduce type checking to existing Python files
hayat01sh1da Apr 11, 2026
f82b414
Introduce type checking to existing Python files
hayat01sh1da Apr 11, 2026
acea098
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 14, 2026
c810f56
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 21, 2026
54d2033
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 22, 2026
6d4ffae
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 22, 2026
728a684
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 22, 2026
0439f24
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 22, 2026
a059287
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 22, 2026
a47bdf2
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 23, 2026
f07d895
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 26, 2026
56f67bd
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 28, 2026
7e5af4f
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da Apr 30, 2026
b2d1ea6
Fix mypy command on GitHub Actions workflow
hayat01sh1da May 1, 2026
277885f
Add .mypy_cache to .gitignore
hayat01sh1da May 1, 2026
0768afe
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 2, 2026
a5b3b31
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 2, 2026
aa34c18
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 4, 2026
df00d8d
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 5, 2026
83925a1
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 9, 2026
b2c2cdb
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 11, 2026
8d369a3
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 12, 2026
991911a
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 12, 2026
40bc4ce
Merge branch 'master' into hayat01sh1da/python/introduce-mypy-typeche…
hayat01sh1da May 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ jobs:
- name: pytest
working-directory: ./python
run: bash run_unittests.sh
# mypy:
# timeout-minutes: 10
# runs-on: ubuntu-latest
# needs: change-detection
# if: needs.change-detection.outputs.python-changes == 'true'
# steps:
# - uses: actions/checkout@v6
# - uses: ./.github/actions/setup-python
# - name: mypy
# working-directory: ./python
# run: mypy .
mypy:
timeout-minutes: 10
runs-on: ubuntu-latest
needs: change-detection
if: needs.change-detection.outputs.python-changes == 'true'
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-python
- name: mypy
working-directory: ./python
env:
MYPYPATH: src
run: mypy --namespace-packages --explicit-package-bases .
9 changes: 4 additions & 5 deletions python/calculator_cli_app/src/application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from args_validation import __validate__
from calculation_query import CalculationQuery
from data_type_conversion import __to_int_with_rescue__
from __future__ import annotations

import sys
sys.path.append('./calculator_cli_app/src')
sys.path.append('./calculator_cli_app/src/lib')
Expand All @@ -9,7 +8,7 @@


class Application:
def __init__(self, args):
def __init__(self, args: list[str]) -> None:
self.args_size = len(args)
if self.args_size > 0:
self.seed = args[0]
Expand All @@ -19,7 +18,7 @@ def __init__(self, args):
self.n = ''
self.calculation_query = CalculationQuery(self.seed)

def run(self):
def run(self) -> None:
__validate__(self.args_size, self.seed, __to_int_with_rescue__(self.n))

result = self.calculation_query.f(__to_int_with_rescue__(self.n))
Expand Down
5 changes: 4 additions & 1 deletion python/calculator_cli_app/src/lib/data_type_conversion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
def __to_int_with_rescue__(n):
from __future__ import annotations


def __to_int_with_rescue__(n: str) -> int | str:
try:
return int(n)
except ValueError:
Expand Down
6 changes: 3 additions & 3 deletions python/calculator_cli_app/src/queries/calculation_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@


class CalculationQuery:
def __init__(self, seed):
def __init__(self, seed: str) -> None:
self.seed = seed
self.uri = os.environ['CALCULATION_API']

def f(self, n):
def f(self, n: int) -> int:
if n == 0:
return 1
elif n == 2:
Expand All @@ -21,7 +21,7 @@ def f(self, n):

# private

def __ask_server__(self, n):
def __ask_server__(self, n: int) -> int:
params = {'seed': self.seed, 'n': n}
req = urllib.request.Request('{}?{}'.format(
self.uri, urllib.parse.urlencode(params)))
Expand Down
5 changes: 4 additions & 1 deletion python/calculator_cli_app/src/validations/args_validation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
def __validate__(args_size, seed, n):
from __future__ import annotations


def __validate__(args_size: int, seed: str, n: int | str) -> None:
if args_size > 2:
print('Too many arguments')
exit(1)
Expand Down
5 changes: 4 additions & 1 deletion python/fibonacci_sequence/src/fibonacci.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
def fibonacci(init_num, iter):
from __future__ import annotations


def fibonacci(init_num: int, iter: int) -> list[int]:
current_num = init_num
next_num = current_num + 1
result = list()
Expand Down
4 changes: 2 additions & 2 deletions python/fizzbuzz/src/fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def fizzbuzz_in_if(num):
def fizzbuzz_in_if(num: int) -> str:
if num % 3 == 0 and num % 5 == 0:
result = 'FizzBuzz'
elif num % 3 == 0:
Expand All @@ -10,7 +10,7 @@ def fizzbuzz_in_if(num):
return result


def fizzbuzz_in_ternary(num):
def fizzbuzz_in_ternary(num: int) -> str:
result = 'FizzBuzz' if num % 3 == 0 and num % 5 == 0 else 'Fizz' if num % 3 == 0 else 'Buzz' if num % 5 == 0 else str(
num)
return result
6 changes: 3 additions & 3 deletions python/letter_inspection/src/application.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class Application:
def __init__(self, str_1, str_2):
def __init__(self, str_1: str, str_2: str) -> None:
self.str_1 = str_1
self.str_2 = str_2

def exactly_equal_size_and_included(self):
def exactly_equal_size_and_included(self) -> bool:
return self.__sort_string__(
self.str_1) == self.__sort_string__(
self.str_2)

# private

def __sort_string__(self, str):
def __sort_string__(self, str: str) -> str:
return ''.join(sorted(str))
4 changes: 2 additions & 2 deletions python/nabeatsu/src/nabeatsu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def go_crazy_in_if(num):
def go_crazy_in_if(num: int) -> str:
if num % 3 == 0 or '3' in str(num):
# Express the status of 'crazy' with '!'
result = str(num) + '!'
Expand All @@ -7,7 +7,7 @@ def go_crazy_in_if(num):
return result


def go_crazy_in_ternary(num):
def go_crazy_in_ternary(num: int) -> str:
# Express the status of 'crazy' with '!'
result = str(num) + '!' if num % 3 == 0 or '3' in str(num) else str(num)
return result
5 changes: 5 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.mypy]
python_version = "3.14"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
Loading