Skip to content

Commit 45bcac1

Browse files
authored
Merge branch 'main' into akran123
2 parents 2410c8a + ceaaaa6 commit 45bcac1

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

.github/workflows/check-function-length.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
echo "max-locals=10" >> .pylintrc
1919
echo "max-args=5" >> .pylintrc
2020
echo "max-statements=15" >> .pylintrc
21+
echo "[MESSAGES CONTROL]" >> .pylintrc
22+
echo "disable=all" >> .pylintrc
23+
echo "enable=design" >> .pylintrc
2124
2225
- name: Run pylint
2326
run: pylint --rcfile=.pylintrc src/

.github/workflows/check-no-external-libs.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,25 @@ jobs:
2222
2323
allowed_modules = {'sys', 'os', 'math', 'random', 'datetime', 're', 'enum'}
2424
25+
def is_internal_module(module_name):
26+
\"\"\" 내부 모듈(`src/` 폴더 내 Python 파일)인지 확인 \"\"\"
27+
module_path = os.path.join('src', module_name.replace('.', '/') + '.py')
28+
module_dir = os.path.join('src', module_name.replace('.', '/'))
29+
return os.path.exists(module_path) or os.path.isdir(module_dir)
30+
2531
def check_imports(file_path):
2632
with open(file_path, 'r', encoding='utf-8') as f:
2733
tree = ast.parse(f.read(), filename=file_path)
2834
for node in ast.walk(tree):
2935
if isinstance(node, ast.Import):
3036
for alias in node.names:
31-
if alias.name not in allowed_modules:
37+
if alias.name not in allowed_modules and not is_internal_module(alias.name):
3238
raise SystemExit(f'❌ External library detected: {alias.name} in {file_path}')
3339
elif isinstance(node, ast.ImportFrom):
34-
if node.module and node.module not in allowed_modules:
40+
if node.module and node.module not in allowed_modules and not is_internal_module(node.module):
3541
raise SystemExit(f'❌ External library detected: {node.module} in {file_path}')
3642
3743
for root, _, files in os.walk('src'):
3844
for file in files:
3945
if file.endswith('.py'):
40-
check_imports(os.path.join(root, file))"
46+
check_imports(os.path.join(root, file))"

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[pytest]
22
pythonpath = src
33
markers =
4-
custom_name: 테스트 설명을 위한 커스텀 마커
4+
custom_name: 테스트 설명을 위한 커스텀 마커
File renamed without changes.

src/lotto/__init__.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
from .lotto import Lotto
1+
# src/lotto/__init__.py
22

3+
# 📌 이 패키지는 로또 관련 기능을 제공하는 모듈입니다.
4+
# 외부에서 `from lotto import Lotto`와 같은 방식으로 사용할 수 있도록
5+
# 필요한 모듈을 여기에 등록하세요.
6+
#
7+
# ✅ 새로운 모듈을 추가할 경우:
8+
# - `from .[모듈명] import [클래스/함수]` 형식으로 추가하세요.
9+
# - 필요한 경우 `__all__`에 추가하여 패키지 외부에서 명확하게 사용할 수 있도록 정의하세요.
10+
# - `flake8`의 F401 경고(`imported but unused`)가 발생하는 경우, `__all__`을 활용해 해결하세요.
311

4-
__all__ = ["Lotto"]
12+
from .lotto import Lotto # 🎲 로또 번호 생성 및 검증을 위한 클래스
13+
14+
# 패키지 외부에서 `from lotto import *` 사용 시 제공할 모듈을 명시적으로 정의합니다.
15+
__all__ = ["Lotto"]
16+
17+
# 💡 예시: 새로운 모듈을 추가할 때
18+
# from .other_module import OtherClass # 🆕 예: 새로운 클래스 추가 시
19+
# __all__.append("OtherClass") # `__all__`에 추가하여 외부에서 접근 가능하게 함.

0 commit comments

Comments
 (0)