-
Notifications
You must be signed in to change notification settings - Fork 5
[로또] 원영진 미션 제출합니다. #5
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
base: main
Are you sure you want to change the base?
Conversation
개발 전, 기능 요구 사항 작성
구매 금액 입력 기능 함수 추가
구입 금액에 해당하는 만큼 로또 수량 계산 함수 추가
구입한 로또 개수만큼 로또를 발행하는 함수 추가 PEP8 Style로 변경 기존 코드 개선 및 주석 추가가
로또 숫자 범위와 로또 크기를 매직넘버상수로 변경
당첨 번호를 입력받고, 검증하는 함수 추가
보너스 번호 입력 함수 추가 보너스 번호 검증
docs: Add feature Edit document 발행된 로또를 당첨 번호, 보너스 번호와 비교하는 함수 추가 기능 추가 문서 작성
당첨 통계 출력 함수 추가
단위 테스트 기능 추가
""" Walkthrough이번 변경 사항은 로또 애플리케이션의 기능 요구사항 문서를 개선하고, 관련 함수와 메서드를 추가하여 입력 검증, 로또 번호 발행, 당첨 번호 및 보너스 번호 비교, 결과 산출 등 주요 기능의 구현을 확장합니다. 또한, Lotto 클래스 내에서 번호 검증 로직과 오류 메시지를 보완하고, Score 열거형을 도입하여 당첨 조건에 따른 결과 처리를 명확하게 했습니다. 테스트 코드도 추가되어 각 기능의 경계 조건과 예외 상황을 포괄적으로 검증하도록 개선되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant U as 사용자
participant M as Main
participant L as Lotto 클래스
U->>M: 구입 금액 입력
M->>M: validate_input_purchase_amount() 호출
M->>L: issuance_lotto()로 로또 번호 발행
U->>M: 당첨 번호 입력
M->>L: compare_winning_number() 호출
U->>M: 보너스 번호 입력
M->>L: validate_bonus_number() 호출
L->>L: calculate_result()로 당첨 결과 계산
M->>U: print_result()로 결과 출력
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
|
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.
Actionable comments posted: 3
🧹 Nitpick comments (12)
src/lotto/lotto.py (2)
39-44
: 자동 로또 생성 로직 확인
요구 사항대로 6개의 랜덤 숫자를 정렬하여 반환합니다. 단, 테스트 시random
함수의 무작위성을 처리하기 위한 Mock이나 시드 설정이 필요할 수 있습니다.🧰 Tools
🪛 GitHub Actions: Check Indentation Depth
[warning] 44-44: Trailing whitespace (trailing-whitespace)
🪛 GitHub Actions: Check PEP8 Style
[error] 39-39: too many blank lines (2)
[warning] 44-44: blank line contains whitespace
83-104
: Score 열거형 및 get_score 메서드 검토
등수별 정보를 명확하게 정의하고,match_count
,bonus_match
로 적절한 Score를 찾는 구조가 명료합니다. PEP8 길이 제한(79자)을 초과하는 line #102가 감지되었으니, 필요하다면 코드를 줄바꿈 해주시면 좋겠습니다. 또한 파일의 마지막 줄(104)에서 최종 개행이 누락되었다는 지적도 있으므로 추가를 권장합니다.🧰 Tools
🪛 GitHub Actions: Check Indentation Depth
[warning] 104-104: Final newline missing (missing-final-newline)
🪛 GitHub Actions: Check PEP8 Style
[error] 102-102: line too long (85 > 79 characters)
[warning] 104-104: no newline at end of file
src/lotto/main.py (3)
25-30
: 구입 금액 입력 및 검증 함수
사용자 입력을 받아 바로 검증 함수에 연결하는 구조가 간단 명료합니다. 단, line #28이 PEP8 기준(79자 초과)을 살짝 넘으므로 필요 시 줄바꿈을 고려해 주세요.🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 28-28: line too long (81 > 79 characters)
66-93
: 결과 출력 함수(print_result)
당첨 통계를 계산하고 출력까지 수행하는 과정이 한 함수에 잘 정리되어 있습니다.
다만 line #79와 #88이 각각 82, 86자로 PEP8 권장 길이를 초과했다는 지적이 있으니, 가독성을 위해 줄바꿈을 고려해 보십시오.🧰 Tools
🪛 GitHub Actions: Check Indentation Depth
[warning] 68-68: Trailing whitespace (trailing-whitespace)
🪛 GitHub Actions: Check PEP8 Style
[warning] 68-68: blank line contains whitespace
[error] 79-79: line too long (82 > 79 characters)
[error] 88-88: line too long (86 > 79 characters)
95-110
: main 함수 로직 확인
로또 구입, 발행, 당첨/보너스 입력, 그리고 최종 결과를 출력하는 전체 흐름이 한눈에 파악됩니다.
- line #99에서 코드 길이가 88자로 PEP8 권장 길이를 초과했다는 지적이 있습니다.
- line #105에서
bonus_number
가 할당되지만 이후에 사용되지 않아 Ruff가 경고(F841)를 표시하므로, 사용하지 않을 경우 해당 변수를 제거하는 것이 좋겠습니다.- bonus_number = input_bonus_number(lotto) + input_bonus_number(lotto)🧰 Tools
🪛 Ruff (0.8.2)
105-105: Local variable
bonus_number
is assigned to but never usedRemove assignment to unused variable
bonus_number
(F841)
🪛 GitHub Actions: Check Indentation Depth
[warning] 106-106: Trailing whitespace (trailing-whitespace)
🪛 GitHub Actions: Check PEP8 Style
[error] 99-99: line too long (88 > 79 characters)
[error] 105-105: local variable 'bonus_number' is assigned to but never used
[warning] 106-106: blank line contains whitespace
docs/README.md (7)
1-14
: 목록 들여쓰기 개선 제안
"기능 요구 사항" 섹션의 목록 항목들이 현재 4칸 들여쓰기로 되어 있습니다. MarkdownLint(MD007) 경고에 따라 2칸 들여쓰기를 적용하여 문서의 일관성과 가독성을 높이는 것을 권장드립니다.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
3-3: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
4-4: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
5-5: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
8-8: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
9-9: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
10-10: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
11-11: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
12-12: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
13-13: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
15-20
: 컴퓨터 기능 섹션: 들여쓰기 일관성 필요
컴퓨터 기능 섹션에서도 항목들이 4칸 들여쓰기로 되어 있는데, 2칸 들여쓰기로 수정하여 전체 문서의 포맷 일관성을 맞추면 좋겠습니다.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
16-16: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
17-17: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
18-18: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
19-19: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
21-27
: 당첨 기준 및 금액 섹션: 들여쓰기 통일 제안
당첨 기준 및 금액 항목들의 들여쓰기도 현재 4칸으로 되어 있습니다. 2칸 들여쓰기를 적용해 목록 형식을 일관되게 관리하는 것을 추천드립니다.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
22-22: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
23-23: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
24-24: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
25-25: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
26-26: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
28-43
: 예외 처리 기능 섹션: 들여쓰기 수정 제안
예외 처리 기능에 대한 항목들도 들여쓰기가 불규칙하게 적용되어 있습니다. 2칸 들여쓰기로 수정하여, 각 항목의 계층 구조를 명확하게 표현할 수 있도록 개선할 것을 권장합니다.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
29-29: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
30-30: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
31-31: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
32-32: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
33-33: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
34-34: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
35-35: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
36-36: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
37-37: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
38-38: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
39-39: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
40-40: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
41-41: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
42-42: Unordered list indentation
Expected: 4; Actual: 8(MD007, ul-indent)
44-71
: 기능 추가 섹션: 상세 기능 나열 및 형식 점검
추가된 기능 목록이 각 함수의 역할과 설명을 명확히 기술하고 있어 이해하기 좋습니다. 다만, 목록의 들여쓰기도 다른 섹션과 같이 2칸 들여쓰기로 일관되게 맞추면 문서 전체의 구조가 더 깔끔해질 것입니다.
47-48
: 함수명 오타 확인
validate_input_prchase_amount()
함수명에 오타가 있는 것 같습니다. 올바른 단어는 "purchase"이므로,validate_input_purchase_amount()
로 수정이 필요할 수 있습니다.
73-75
: 오류 수정 및 기능 수정 섹션 검토
'오류 수정'과 '기능 수정' 섹션이 현재 내용이 없는 빈 상태입니다. 실제 수정 사항이 있다면 해당 내용을 추가하거나, 불필요한 경우 이 섹션들을 제거하는 것을 고려해 보세요.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
docs/README.md
(1 hunks)src/lotto/lotto.py
(1 hunks)src/lotto/main.py
(1 hunks)tests/lotto/test_lotto.py
(1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
src/lotto/main.py
105-105: Local variable bonus_number
is assigned to but never used
Remove assignment to unused variable bonus_number
(F841)
🪛 GitHub Check: codecov/patch
src/lotto/main.py
[warning] 19-19: src/lotto/main.py#L19
Added line #L19 was not covered by tests
[warning] 21-21: src/lotto/main.py#L21
Added line #L21 was not covered by tests
[warning] 44-45: src/lotto/main.py#L44-L45
Added lines #L44 - L45 were not covered by tests
src/lotto/lotto.py
[warning] 13-13: src/lotto/lotto.py#L13
Added line #L13 was not covered by tests
[warning] 48-48: src/lotto/lotto.py#L48
Added line #L48 was not covered by tests
[warning] 53-53: src/lotto/lotto.py#L53
Added line #L53 was not covered by tests
🪛 GitHub Actions: Check Indentation Depth
src/lotto/main.py
[warning] 64-64: Trailing whitespace (trailing-whitespace)
[warning] 68-68: Trailing whitespace (trailing-whitespace)
[warning] 106-106: Trailing whitespace (trailing-whitespace)
src/lotto/lotto.py
[warning] 44-44: Trailing whitespace (trailing-whitespace)
[warning] 49-49: Trailing whitespace (trailing-whitespace)
[warning] 54-54: Trailing whitespace (trailing-whitespace)
[warning] 63-63: Trailing whitespace (trailing-whitespace)
[warning] 104-104: Final newline missing (missing-final-newline)
🪛 GitHub Actions: Check PEP8 Style
src/lotto/main.py
[error] 28-28: line too long (81 > 79 characters)
[error] 42-42: missing whitespace after ','
[warning] 64-64: blank line contains whitespace
[warning] 68-68: blank line contains whitespace
[error] 79-79: line too long (82 > 79 characters)
[error] 88-88: line too long (86 > 79 characters)
[error] 99-99: line too long (88 > 79 characters)
[error] 105-105: local variable 'bonus_number' is assigned to but never used
[warning] 106-106: blank line contains whitespace
src/lotto/lotto.py
[error] 22-22: too many blank lines (2)
[error] 31-31: too many blank lines (2)
[error] 39-39: too many blank lines (2)
[warning] 44-44: blank line contains whitespace
[error] 46-46: too many blank lines (2)
[warning] 49-49: blank line contains whitespace
[error] 51-51: too many blank lines (2)
[warning] 54-54: blank line contains whitespace
[error] 56-56: too many blank lines (2)
[warning] 63-63: blank line contains whitespace
[error] 65-65: too many blank lines (2)
[error] 72-72: too many blank lines (2)
[error] 102-102: line too long (85 > 79 characters)
[warning] 104-104: no newline at end of file
🪛 markdownlint-cli2 (0.17.2)
docs/README.md
3-3: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
4-4: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
5-5: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
8-8: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
9-9: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
10-10: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
11-11: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
12-12: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
13-13: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
16-16: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
17-17: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
18-18: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
19-19: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
22-22: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
23-23: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
24-24: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
25-25: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
26-26: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
29-29: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
30-30: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
31-31: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
32-32: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
33-33: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
34-34: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
35-35: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
36-36: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
37-37: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
38-38: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
39-39: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
40-40: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
41-41: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
42-42: Unordered list indentation
Expected: 4; Actual: 8
(MD007, ul-indent)
🪛 GitHub Actions: Check No External Libraries
src/lotto/lotto.py
[error] 1-1: External library detected: typing in src/lotto/lotto.py
🔇 Additional comments (23)
src/lotto/lotto.py (9)
2-3
: Enum 모듈과 random 모듈 추가 확인
두 모듈 모두 Python 표준 라이브러리이므로 별다른 문제는 없어 보입니다.
6-7
: 매직넘버를 상수화하여 가독성 확보
LOTTO_SIZE와 LOTTO_NUMBER_RANGE를 상수로 정의한 것은 유지보수에 유리합니다.
11-13
: numbers 매개변수의 기본값 처리 확인
numbers가 None일 때 자동 발행 로직을 적용하는 설계는 유연성을 높입니다. 다만 line #13(issuance_lotto 호출)이 테스트 커버리지에서 누락된 경고가 있으니, 해당 로직을 테스트해보시기 바랍니다.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 13-13: src/lotto/lotto.py#L13
Added line #L13 was not covered by tests
23-28
: 로또 번호 검증 로직 확인
개수, 범위, 중복 여부를 체크하는 로직이 명확하게 잘 구성되어 있습니다. 예외 메시지도 사용자가 이해하기 쉽게 작성되었습니다.
31-37
: 보너스 번호 검증 로직 확인
기존 로또 번호와 중복되는지, 범위가 적절한지 검사하는 로직이 알맞게 동작합니다.🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 31-31: too many blank lines (2)
46-48
: str 메서드 테스트 누락 주의
로또 번호 리스트를 문자열로 변환하는 로직은 문제 없어 보입니다. 다만 line #48이 테스트되지 않았다는 경고가 있으므로 유의해 주세요.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 48-48: src/lotto/lotto.py#L48
Added line #L48 was not covered by tests🪛 GitHub Actions: Check PEP8 Style
[error] 46-46: too many blank lines (2)
51-53
: get_numbers 메서드 테스트 누락 주의
로또 번호 배열을 반환하는 간단한 메서드이므로, 단위 테스트에서 간단히 커버리지를 보완할 수 있습니다.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 53-53: src/lotto/lotto.py#L53
Added line #L53 was not covered by tests🪛 GitHub Actions: Check PEP8 Style
[error] 51-51: too many blank lines (2)
56-63
: 당첨 숫자 비교 로직 검토
요소를 순회하며 일치 여부를 카운팅하는 구현은 간단하지만, 로또 번호가 많아도 O(n)에 해당하므로 성능에 큰 문제는 없겠습니다.🧰 Tools
🪛 GitHub Actions: Check Indentation Depth
[warning] 63-63: Trailing whitespace (trailing-whitespace)
🪛 GitHub Actions: Check PEP8 Style
[error] 56-56: too many blank lines (2)
[warning] 63-63: blank line contains whitespace
65-70
: 보너스 번호 비교 로직 확인
보너스 번호가 발행된 번호에 포함되어 있는지를 간단히 확인 후 정수로 반환하는 구조가 명확합니다.🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 65-65: too many blank lines (2)
tests/lotto/test_lotto.py (7)
24-31
: 로또 번호 범위 초과 예외 테스트 추가
1~45 범위를 벗어난 경우(ValueError) 발생 여부를 검사하는 것으로, 유의미한 예외 테스트가 잘 작성되었습니다.
33-39
: 보너스 번호 중복 예외 테스트
당첨 번호와 중복된 보너스 번호 입력 시 ValueError 발생 여부를 정확히 확인하는 테스트입니다.
41-49
: 보너스 번호 범위 초과 예외 테스트
1~45 범위를 벗어나면 ValueError를 발생하는지 확인하는 테스트로, 가능한 경계값을 잘 커버하고 있습니다.
51-56
: 로또 자동 발행 개수 테스트
자동 발행된 로또 번호가 정확히 6개인지 검사하는 로직으로, 명세에 부합합니다.
58-63
: 로또 자동 발행 정렬 여부 테스트
발행된 로또 번호가 오름차순 정렬인지 확인하는 로직으로, 로또 발행 기능 검증에 도움이 됩니다.
65-71
: 당첨 번호 비교 테스트
발행된 번호와 당첨 번호를 비교하여 일치 개수를 확인하는 테스트로, 정상 동작을 확인할 수 있습니다.
73-83
: 보너스 번호 비교 테스트
보너스 번호가 발행 번호에 포함될 경우와 포함되지 않을 경우를 각각 테스트하여 로직을 견고하게 검증합니다.src/lotto/main.py (7)
1-2
: Lotto, Score 모듈 임포트
같은 프로젝트 내 모듈 임포트로 보이므로 문제 없어 보입니다.
4-4
: 로또 단가 상수 선언
매직넘버를 상수화하여 가독성과 유지보수성을 높였습니다.
7-13
: 정수 검증 함수(is_number)
문자열을 정수로 변환하고 실패 시 ValueError를 발생시키는 로직은 입력 검증에 유용합니다.
15-23
: 구입 금액 검증 로직
양의 정수 여부와 1000원 단위 구매인지 검사하는 로직이 적절합니다. line #19와 #21에 대한 테스트 커버리지 경고가 있으니 주의해 주세요.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 19-19: src/lotto/main.py#L19
Added line #L19 was not covered by tests
[warning] 21-21: src/lotto/main.py#L21
Added line #L21 was not covered by tests
39-46
: 입력 문자열 -> 정수 리스트 변환 함수
문자열을 파싱해 정수 리스트를 생성하는 로직이 의미에 맞게 구현되었습니다. 단, line #44~45가 테스트되지 않았다는 경고가 있으니, 예외 발생 케이스에 대한 테스트도 추가 고려해 보세요.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 44-45: src/lotto/main.py#L44-L45
Added lines #L44 - L45 were not covered by tests🪛 GitHub Actions: Check PEP8 Style
[error] 42-42: missing whitespace after ','
48-55
: 당첨 번호 입력 함수
입력된 문자열을 리스트로 변환하고 Lotto 객체로 생성해 예외를 처리하는 체계가 명확합니다.
57-64
: 보너스 번호 입력 함수
추가로, 메인 로직에서 반환된bonus_number
가 사용되지 않는다는 경고가 있으니 참고 바랍니다.🧰 Tools
🪛 GitHub Actions: Check Indentation Depth
[warning] 64-64: Trailing whitespace (trailing-whitespace)
🪛 GitHub Actions: Check PEP8 Style
[warning] 64-64: blank line contains whitespace
src/lotto/lotto.py
Outdated
def calculate_result(self, numbers_list: List[list]): | ||
"""발행한 로또를 순서대로 당첨 번호, 보너스 번호와 비교""" | ||
self.numbers_list = numbers_list | ||
self.result_list = [0 for _ in range(len(numbers_list))] | ||
for i in range(len(self.result_list)): | ||
count_winning = self.compare_winning_number(self.numbers_list[i]) | ||
count_bonus = self.compare_bonus_number(self.numbers_list[i]) | ||
self.result_list[i] = [count_winning, count_bonus] | ||
return self.result_list | ||
|
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.
🛠️ Refactor suggestion
결과 계산 로직 확인
numbers_list
를 순회하며 당첨 번호와 보너스 번호를 각각 비교해 result_list
에 저장하는 로직은 목적에 부합합니다. 다만 self.numbers_list
와 self.result_list
가 초기화 시점에 실제 리스트 형태로 설정되어야 정상 동작이 보장됩니다.
🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 72-72: too many blank lines (2)
src/lotto/lotto.py
Outdated
self.bonus_number = int | ||
self.numbers_list = List[list] | ||
self.result_list = List[int] | ||
self.statistics_list = List[list] |
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.
인스턴스 변수 초기화 방식에 대한 문제
self.bonus_number = int
, self.numbers_list = List[list]
, self.result_list = List[int]
, self.statistics_list = List[list]
구문은 자료형만 대입하고 실제 값을 설정하지 않아 의도대로 동작하지 않을 가능성이 큽니다.
아래 예시처럼 실제 기본값을 주는 식으로 수정해주세요:
- self.bonus_number = int
- self.numbers_list = List[list]
- self.result_list = List[int]
- self.statistics_list = List[list]
+ self.bonus_number: int = 0
+ self.numbers_list: List[List[int]] = []
+ self.result_list: List[int] = []
+ self.statistics_list: List[List[int]] = []
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
self.bonus_number = int | |
self.numbers_list = List[list] | |
self.result_list = List[int] | |
self.statistics_list = List[list] | |
self.bonus_number: int = 0 | |
self.numbers_list: List[List[int]] = [] | |
self.result_list: List[int] = [] | |
self.statistics_list: List[List[int]] = [] |
# 구매 가능한 로또 개수 계산 | ||
def generate_lotto_quantity(purcahse_amount): | ||
lotto_quantity = purcahse_amount // LOTTO_EACH_PRICE | ||
print("\n{0}개를 구매했습니다.".format(lotto_quantity)) | ||
return lotto_quantity | ||
|
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.
🛠️ Refactor suggestion
로또 개수 생성 함수
purcahse_amount
파라미터의 철자가 오타로 보이며, 변수 명을 purchase_amount
로 수정하는 것을 권장합니다.
-def generate_lotto_quantity(purcahse_amount):
+def generate_lotto_quantity(purchase_amount):
lotto_quantity = purchase_amount // LOTTO_EACH_PRICE
...
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# 구매 가능한 로또 개수 계산 | |
def generate_lotto_quantity(purcahse_amount): | |
lotto_quantity = purcahse_amount // LOTTO_EACH_PRICE | |
print("\n{0}개를 구매했습니다.".format(lotto_quantity)) | |
return lotto_quantity | |
# 구매 가능한 로또 개수 계산 | |
def generate_lotto_quantity(purchase_amount): | |
lotto_quantity = purchase_amount // LOTTO_EACH_PRICE | |
print("\n{0}개를 구매했습니다.".format(lotto_quantity)) | |
return lotto_quantity |
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.
Actionable comments posted: 5
♻️ Duplicate comments (1)
src/lotto/lotto.py (1)
16-19
:⚠️ Potential issue인스턴스 변수 초기화 방식 수정 필요
타입 어노테이션만 설정하고 실제 값을 초기화하지 않았습니다.
다음과 같이 수정해주세요:
-self.bonus_number = int -self.numbers_list = List[list] -self.result_list = List[int] -self.statistics_list = List[list] +self.bonus_number: int = 0 +self.numbers_list: list[list[int]] = [] +self.result_list: list[int] = [] +self.statistics_list: list[list[int]] = []
🧹 Nitpick comments (4)
src/lotto/main.py (4)
7-13
: 타입 힌트를 추가하면 좋을 것 같습니다.코드의 가독성과 타입 안정성을 높이기 위해 타입 힌트를 추가하는 것을 제안합니다.
-def is_number(data): +def is_number(data: str) -> int:
39-46
: PEP8 스타일 가이드를 준수해주세요.쉼표 뒤에 공백을 추가하여 가독성을 개선해주세요.
- data = list(map(int, data.replace(" ","").split(","))) + data = list(map(int, data.replace(" ", "").split(",")))🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 44-45: src/lotto/main.py#L44-L45
Added lines #L44 - L45 were not covered by tests🪛 GitHub Actions: Check PEP8 Style
[warning] 42-42: E231 missing whitespace after ','
95-110
: 로또 발행 라인을 분리해주세요.PEP8 가이드라인을 준수하기 위해 긴 줄을 분리하는 것이 좋겠습니다.
- issued_lotto_list = [Lotto.issuance_lotto() for _ in range(lotto_quantity)] + issued_lotto_list = [ + Lotto.issuance_lotto() + for _ in range(lotto_quantity) + ]🧰 Tools
🪛 Ruff (0.8.2)
105-105: Local variable
bonus_number
is assigned to but never usedRemove assignment to unused variable
bonus_number
(F841)
🪛 GitHub Actions: Check PEP8 Style
[error] 99-99: E501 line too long (88 > 79 characters)
[warning] 105-105: F841 local variable 'bonus_number' is assigned to but never used
1-114
: 함수들에 독스트링을 추가하면 좋을 것 같습니다.각 함수의 목적, 매개변수, 반환값을 설명하는 독스트링을 추가하여 문서화를 개선해주세요.
예시:
def validate_input_purchase_amount(data: str) -> int: """ 구입 금액이 유효한지 검증합니다. Args: data (str): 검증할 구입 금액 문자열 Returns: int: 검증된 구입 금액 Raises: ValueError: 구입 금액이 유효하지 않은 경우 """🧰 Tools
🪛 Ruff (0.8.2)
105-105: Local variable
bonus_number
is assigned to but never usedRemove assignment to unused variable
bonus_number
(F841)
🪛 GitHub Check: codecov/patch
[warning] 19-19: src/lotto/main.py#L19
Added line #L19 was not covered by tests
[warning] 21-21: src/lotto/main.py#L21
Added line #L21 was not covered by tests
[warning] 44-45: src/lotto/main.py#L44-L45
Added lines #L44 - L45 were not covered by tests🪛 GitHub Actions: Check PEP8 Style
[error] 28-28: E501 line too long (81 > 79 characters)
[warning] 42-42: E231 missing whitespace after ','
[error] 79-79: E501 line too long (82 > 79 characters)
[error] 88-88: E501 line too long (86 > 79 characters)
[error] 99-99: E501 line too long (88 > 79 characters)
[warning] 105-105: F841 local variable 'bonus_number' is assigned to but never used
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/lotto/__init__.py
(1 hunks)src/lotto/lotto.py
(1 hunks)src/lotto/main.py
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/lotto/init.py
🧰 Additional context used
🪛 Ruff (0.8.2)
src/lotto/main.py
105-105: Local variable bonus_number
is assigned to but never used
Remove assignment to unused variable bonus_number
(F841)
🪛 GitHub Check: codecov/patch
src/lotto/main.py
[warning] 19-19: src/lotto/main.py#L19
Added line #L19 was not covered by tests
[warning] 21-21: src/lotto/main.py#L21
Added line #L21 was not covered by tests
[warning] 44-45: src/lotto/main.py#L44-L45
Added lines #L44 - L45 were not covered by tests
src/lotto/lotto.py
[warning] 13-13: src/lotto/lotto.py#L13
Added line #L13 was not covered by tests
[warning] 48-48: src/lotto/lotto.py#L48
Added line #L48 was not covered by tests
[warning] 53-53: src/lotto/lotto.py#L53
Added line #L53 was not covered by tests
🪛 GitHub Actions: Check PEP8 Style
src/lotto/main.py
[error] 28-28: E501 line too long (81 > 79 characters)
[warning] 42-42: E231 missing whitespace after ','
[error] 79-79: E501 line too long (82 > 79 characters)
[error] 88-88: E501 line too long (86 > 79 characters)
[error] 99-99: E501 line too long (88 > 79 characters)
[warning] 105-105: F841 local variable 'bonus_number' is assigned to but never used
src/lotto/lotto.py
[warning] 22-22: E303 too many blank lines (2)
[warning] 31-31: E303 too many blank lines (2)
[warning] 39-39: E303 too many blank lines (2)
[warning] 46-46: E303 too many blank lines (2)
[warning] 51-51: E303 too many blank lines (2)
[warning] 56-56: E303 too many blank lines (2)
[warning] 65-65: E303 too many blank lines (2)
[warning] 72-72: E303 too many blank lines (2)
[error] 102-102: E501 line too long (85 > 79 characters)
🪛 GitHub Actions: Check No External Libraries
src/lotto/lotto.py
[error] 1-1: External library detected: typing in src/lotto/lotto.py
🔇 Additional comments (6)
src/lotto/lotto.py (2)
22-37
: 검증 로직이 잘 구현되어 있습니다!
- 상수를 활용한 검증
- 명확한 한글 에러 메시지
- 중복 검사 및 범위 검사가 잘 구현됨
🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[warning] 22-22: E303 too many blank lines (2)
[warning] 31-31: E303 too many blank lines (2)
39-54
: 유틸리티 메서드 테스트 커버리지 개선 필요
issuance_lotto()
,__str__()
,get_numbers()
메서드에 대한 테스트 케이스가 누락되었습니다.다음과 같은 테스트 케이스 추가를 제안드립니다:
- 랜덤 로또 번호 생성 검증
- 문자열 변환 결과 검증
- 번호 리스트 반환 검증
테스트 코드를 생성해드릴까요?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 48-48: src/lotto/lotto.py#L48
Added line #L48 was not covered by tests
[warning] 53-53: src/lotto/lotto.py#L53
Added line #L53 was not covered by tests🪛 GitHub Actions: Check PEP8 Style
[warning] 39-39: E303 too many blank lines (2)
[warning] 46-46: E303 too many blank lines (2)
[warning] 51-51: E303 too many blank lines (2)
src/lotto/main.py (4)
1-4
: 잘 정의된 상수와 임포트문입니다!매직 넘버를 상수로 분리하여 코드의 가독성과 유지보수성을 높였습니다.
15-23
: 오류 케이스에 대한 테스트 커버리지가 필요합니다.음수 입력과 1,000원 단위가 아닌 경우에 대한 테스트가 누락되어 있습니다.
테스트 케이스 예시를 제공해드릴까요?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 19-19: src/lotto/main.py#L19
Added line #L19 was not covered by tests
[warning] 21-21: src/lotto/main.py#L21
Added line #L21 was not covered by tests
32-37
: 매개변수 이름의 오타를 수정해주세요.
purcahse_amount
를purchase_amount
로 수정하는 것이 좋겠습니다.
1-114
: 전반적으로 잘 구현된 코드입니다!다음 사항들만 개선하면 더 좋을 것 같습니다:
- 오타 수정 (purcahse, bouns)
- PEP8 스타일 가이드 준수
- 테스트 커버리지 개선
- 문서화 (독스트링) 추가
🧰 Tools
🪛 Ruff (0.8.2)
105-105: Local variable
bonus_number
is assigned to but never usedRemove assignment to unused variable
bonus_number
(F841)
🪛 GitHub Check: codecov/patch
[warning] 19-19: src/lotto/main.py#L19
Added line #L19 was not covered by tests
[warning] 21-21: src/lotto/main.py#L21
Added line #L21 was not covered by tests
[warning] 44-45: src/lotto/main.py#L44-L45
Added lines #L44 - L45 were not covered by tests🪛 GitHub Actions: Check PEP8 Style
[error] 28-28: E501 line too long (81 > 79 characters)
[warning] 42-42: E231 missing whitespace after ','
[error] 79-79: E501 line too long (82 > 79 characters)
[error] 88-88: E501 line too long (86 > 79 characters)
[error] 99-99: E501 line too long (88 > 79 characters)
[warning] 105-105: F841 local variable 'bonus_number' is assigned to but never used
from typing import List | ||
from enum import Enum | ||
import random | ||
|
||
|
||
LOTTO_SIZE = 6 # 로또 길이 매직넘버상수 | ||
LOTTO_NUMBER_RANGE = range(1, 46) # 로또 숫자 범위 매직넘버상수 | ||
|
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.
외부 라이브러리 사용 제한 위반
typing
모듈은 외부 라이브러리로 감지되었습니다. 프로젝트 요구사항에 따라 외부 라이브러리 사용이 제한되어 있습니다.
다음과 같이 수정해주세요:
-from typing import List
타입 힌트가 필요한 경우 Python 3.9+ 내장 타입을 사용할 수 있습니다:
numbers: list[int] # Python 3.9+
🧰 Tools
🪛 GitHub Actions: Check No External Libraries
[error] 1-1: External library detected: typing in src/lotto/lotto.py
src/lotto/lotto.py
Outdated
def compare_winning_number(self, numbers: List[int]): | ||
"""당첨 번호와 발행 번호를 비교""" | ||
count = 0 | ||
for i in numbers: | ||
if i in self._numbers: | ||
count += 1 | ||
return count | ||
|
||
|
||
def compare_bonus_number(self, numbers: List[int]): | ||
"""보너스 번호와 발행 번호를 비교""" | ||
if self.bonus_number in numbers: | ||
return 1 | ||
return 0 | ||
|
||
|
||
def calculate_result(self, numbers_list: List[list]): | ||
"""발행한 로또를 순서대로 당첨 번호, 보너스 번호와 비교""" | ||
self.numbers_list = numbers_list | ||
self.result_list = [0 for _ in range(len(numbers_list))] | ||
for i in range(len(self.result_list)): | ||
count_winning = self.compare_winning_number(self.numbers_list[i]) | ||
count_bonus = self.compare_bonus_number(self.numbers_list[i]) | ||
self.result_list[i] = [count_winning, count_bonus] | ||
return self.result_list | ||
|
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.
🛠️ Refactor suggestion
코드 포맷팅 개선 필요
메서드 사이의 빈 줄이 PEP8 스타일 가이드를 위반하고 있습니다.
메서드 사이의 빈 줄을 2줄에서 1줄로 수정해주세요.
🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[warning] 56-56: E303 too many blank lines (2)
[warning] 65-65: E303 too many blank lines (2)
[warning] 72-72: E303 too many blank lines (2)
src/lotto/lotto.py
Outdated
당첨 번호 개수와 보너스 번호 여부를 받아 해당하는 Score 반환 | ||
""" | ||
for score in cls: | ||
if score.match_count == match_count and score.bonus_match == bonus_match: |
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.
🛠️ Refactor suggestion
줄 길이 제한 초과
해당 라인이 PEP8의 줄 길이 제한(79자)을 초과했습니다.
다음과 같이 수정해주세요:
- if score.match_count == match_count and score.bonus_match == bonus_match:
+ if (score.match_count == match_count and
+ score.bonus_match == bonus_match):
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if score.match_count == match_count and score.bonus_match == bonus_match: | |
if (score.match_count == match_count and | |
score.bonus_match == bonus_match): |
🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 102-102: E501 line too long (85 > 79 characters)
# 보너스 번호를 입력받고 검증하는 함수 | ||
def input_bonus_number(lotto): | ||
print("\n보너스 번호를 입력해 주세요.") | ||
bouns_number = input() # 보너스 번호 입력 | ||
bouns_number = is_number(bouns_number) # 보너스 번호를 int형으로 변환 | ||
lotto.validate_bonus_number(bouns_number) # 보너스 번호 검증증 | ||
return bouns_number | ||
|
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.
여러 가지 개선이 필요합니다.
bonus_number
변수가 사용되지 않고 있습니다.- 'bouns_number'에 오타가 있습니다 ('bonus_number'가 올바른 철자).
- bouns_number = input()
- bouns_number = is_number(bouns_number)
- lotto.validate_bonus_number(bouns_number)
- return bouns_number
+ bonus_number = input()
+ bonus_number = is_number(bonus_number)
+ lotto.validate_bonus_number(bonus_number)
+ return bonus_number
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# 보너스 번호를 입력받고 검증하는 함수 | |
def input_bonus_number(lotto): | |
print("\n보너스 번호를 입력해 주세요.") | |
bouns_number = input() # 보너스 번호 입력 | |
bouns_number = is_number(bouns_number) # 보너스 번호를 int형으로 변환 | |
lotto.validate_bonus_number(bouns_number) # 보너스 번호 검증증 | |
return bouns_number | |
# 보너스 번호를 입력받고 검증하는 함수 | |
def input_bonus_number(lotto): | |
print("\n보너스 번호를 입력해 주세요.") | |
bonus_number = input() # 보너스 번호 입력 | |
bonus_number = is_number(bonus_number) # 보너스 번호를 int형으로 변환 | |
lotto.validate_bonus_number(bonus_number) # 보너스 번호 검증증 | |
return bonus_number |
def print_result(result_list, purchase_amount): | ||
print("\n당첨 통계\n---") | ||
|
||
# 등수별 당첨 개수 저장 딕셔너리 초기화 | ||
score_count = {score: 0 for score in Score if score != Score.NONE} | ||
|
||
# 당첨 개수 세기 | ||
for match_count, bonus_match in result_list: | ||
score = Score.get_score(match_count, bonus_match) | ||
if score != Score.NONE: | ||
score_count[score] += 1 | ||
|
||
# 총 당첨 금액 계산 | ||
total_prize = sum(score.prize * count for score, count in score_count.items()) | ||
|
||
# 결과 출력 | ||
for score in Score: | ||
if score == Score.NONE: | ||
continue # NONE 등급(낙첨)은 출력하지 않음 | ||
description = f"{score.match_count}개 일치" | ||
if score.bonus_match == 1: | ||
description += ", 보너스 볼 일치" | ||
print(f"{description} ({format(score.prize, ',d')}원) - {score_count[score]}개") | ||
|
||
# 수익률 계산 및 출력 | ||
revenue_rate = (total_prize / purchase_amount) * 100 | ||
print(f"총 수익률은 {revenue_rate:.1f}%입니다.") | ||
|
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.
🛠️ Refactor suggestion
코드 가독성 개선이 필요합니다.
- 긴 줄들을 PEP8 길이 제한(79자)에 맞게 분리해주세요.
- 결과 출력 로직을 더 작은 함수들로 분리하면 좋을 것 같습니다.
- print(f"{description} ({format(score.prize, ',d')}원) - {score_count[score]}개")
+ prize_str = format(score.prize, ',d')
+ print(f"{description} ({prize_str}원) - {score_count[score]}개")
- total_prize = sum(score.prize * count for score, count in score_count.items())
+ total_prize = sum(
+ score.prize * count
+ for score, count in score_count.items()
+ )
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def print_result(result_list, purchase_amount): | |
print("\n당첨 통계\n---") | |
# 등수별 당첨 개수 저장 딕셔너리 초기화 | |
score_count = {score: 0 for score in Score if score != Score.NONE} | |
# 당첨 개수 세기 | |
for match_count, bonus_match in result_list: | |
score = Score.get_score(match_count, bonus_match) | |
if score != Score.NONE: | |
score_count[score] += 1 | |
# 총 당첨 금액 계산 | |
total_prize = sum(score.prize * count for score, count in score_count.items()) | |
# 결과 출력 | |
for score in Score: | |
if score == Score.NONE: | |
continue # NONE 등급(낙첨)은 출력하지 않음 | |
description = f"{score.match_count}개 일치" | |
if score.bonus_match == 1: | |
description += ", 보너스 볼 일치" | |
print(f"{description} ({format(score.prize, ',d')}원) - {score_count[score]}개") | |
# 수익률 계산 및 출력 | |
revenue_rate = (total_prize / purchase_amount) * 100 | |
print(f"총 수익률은 {revenue_rate:.1f}%입니다.") | |
def print_result(result_list, purchase_amount): | |
print("\n당첨 통계\n---") | |
# 등수별 당첨 개수 저장 딕셔너리 초기화 | |
score_count = {score: 0 for score in Score if score != Score.NONE} | |
# 당첨 개수 세기 | |
for match_count, bonus_match in result_list: | |
score = Score.get_score(match_count, bonus_match) | |
if score != Score.NONE: | |
score_count[score] += 1 | |
# 총 당첨 금액 계산 | |
total_prize = sum( | |
score.prize * count | |
for score, count in score_count.items() | |
) | |
# 결과 출력 | |
for score in Score: | |
if score == Score.NONE: | |
continue # NONE 등급(낙첨)은 출력하지 않음 | |
description = f"{score.match_count}개 일치" | |
if score.bonus_match == 1: | |
description += ", 보너스 볼 일치" | |
prize_str = format(score.prize, ',d') | |
print(f"{description} ({prize_str}원) - {score_count[score]}개") | |
# 수익률 계산 및 출력 | |
revenue_rate = (total_prize / purchase_amount) * 100 | |
print(f"총 수익률은 {revenue_rate:.1f}%입니다.") |
🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 79-79: E501 line too long (82 > 79 characters)
[error] 88-88: E501 line too long (86 > 79 characters)
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/lotto/main.py (2)
43-43
: 문자열 분할 포맷팅 개선쉼표 뒤에 공백이 필요합니다:
- data = list(map(int, data.replace(" ","").split(","))) + data = list(map(int, data.replace(" ", "").split(", ")))🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 43-43: missing whitespace after ','
100-100
: 리스트 컴프리헨션 줄 길이 개선긴 줄을 여러 줄로 나누어 가독성을 개선해주세요:
- issued_lotto_list = [Lotto.issuance_lotto() for _ in range(lotto_quantity)] + issued_lotto_list = [ + Lotto.issuance_lotto() + for _ in range(lotto_quantity) + ]🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 100-100: line too long (88 > 79 characters)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/lotto/__init__.py
(2 hunks)src/lotto/lotto.py
(1 hunks)src/lotto/main.py
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lotto/init.py
🧰 Additional context used
🪛 Ruff (0.8.2)
src/lotto/main.py
106-106: Local variable bonus_number
is assigned to but never used
Remove assignment to unused variable bonus_number
(F841)
🪛 GitHub Check: codecov/patch
src/lotto/main.py
[warning] 20-20: src/lotto/main.py#L20
Added line #L20 was not covered by tests
[warning] 22-22: src/lotto/main.py#L22
Added line #L22 was not covered by tests
[warning] 45-46: src/lotto/main.py#L45-L46
Added lines #L45 - L46 were not covered by tests
src/lotto/lotto.py
[warning] 13-13: src/lotto/lotto.py#L13
Added line #L13 was not covered by tests
[warning] 44-44: src/lotto/lotto.py#L44
Added line #L44 was not covered by tests
[warning] 48-48: src/lotto/lotto.py#L48
Added line #L48 was not covered by tests
🪛 GitHub Actions: Check PEP8 Style
src/lotto/main.py
[error] 29-29: line too long (81 > 79 characters)
[error] 43-43: missing whitespace after ','
[error] 80-80: line too long (82 > 79 characters)
[error] 89-89: line too long (86 > 79 characters)
[error] 100-100: line too long (88 > 79 characters)
[warning] 106-106: local variable 'bonus_number' is assigned to but never used
src/lotto/lotto.py
[warning] 28-28: blank line contains whitespace
[error] 94-94: line too long (85 > 79 characters)
🪛 GitHub Actions: Check No External Libraries
src/lotto/lotto.py
[error] 1-1: External library detected: typing in src/lotto/lotto.py
🪛 GitHub Actions: Check Indentation Depth
src/lotto/lotto.py
[warning] 28-28: Trailing whitespace (trailing-whitespace)
🔇 Additional comments (7)
src/lotto/lotto.py (3)
1-8
: 외부 라이브러리 사용 제한 위반
typing
모듈은 외부 라이브러리로 감지되었습니다. Python 3.9+ 내장 타입을 사용하도록 수정해주세요.-from typing import List
🧰 Tools
🪛 GitHub Actions: Check No External Libraries
[error] 1-1: External library detected: typing in src/lotto/lotto.py
16-19
: 인스턴스 변수 초기화 방식 수정 필요타입만 대입하는 대신 실제 초기값을 설정해주세요:
- self.bonus_number = int - self.numbers_list = List[list] - self.result_list = List[int] - self.statistics_list = List[list] + self.bonus_number: int = 0 + self.numbers_list: list[list] = [] + self.result_list: list[int] = [] + self.statistics_list: list[list] = []
94-94
: 줄 길이 제한 초과해당 라인이 PEP8의 줄 길이 제한(79자)을 초과했습니다. 다음과 같이 수정해주세요:
- if score.match_count == match_count and score.bonus_match == bonus_match: + if (score.match_count == match_count and + score.bonus_match == bonus_match):🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 94-94: line too long (85 > 79 characters)
src/lotto/main.py (4)
34-37
: 함수 파라미터 이름 오타 수정
purcahse_amount
파라미터의 철자가 잘못되었습니다:-def generate_lotto_quantity(purcahse_amount): - lotto_quantity = purcahse_amount // LOTTO_EACH_PRICE +def generate_lotto_quantity(purchase_amount): + lotto_quantity = purchase_amount // LOTTO_EACH_PRICE
61-64
: 변수 이름 오타 수정'bouns_number'에 오타가 있습니다:
- bouns_number = input() - bouns_number = is_number(bouns_number) - lotto.validate_bonus_number(bouns_number) + bonus_number = input() + bonus_number = is_number(bonus_number) + lotto.validate_bonus_number(bonus_number)
80-89
: 코드 가독성 개선 필요긴 줄들을 PEP8 길이 제한(79자)에 맞게 분리해주세요:
- total_prize = sum(score.prize * count for score, count in score_count.items()) + total_prize = sum( + score.prize * count + for score, count in score_count.items() + ) - print(f"{description} ({format(score.prize, ',d')}원) - {score_count[score]}개") + prize_str = format(score.prize, ',d') + print(f"{description} ({prize_str}원) - {score_count[score]}개")🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 80-80: line too long (82 > 79 characters)
[error] 89-89: line too long (86 > 79 characters)
106-106
: 미사용 변수 제거
bonus_number
변수가 할당되었지만 사용되지 않습니다. 이 변수가 필요하다면 활용하고, 그렇지 않다면 제거해주세요.🧰 Tools
🪛 Ruff (0.8.2)
106-106: Local variable
bonus_number
is assigned to but never usedRemove assignment to unused variable
bonus_number
(F841)
🪛 GitHub Actions: Check PEP8 Style
[warning] 106-106: local variable 'bonus_number' is assigned to but never used
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/lotto/lotto.py (1)
94-94
: 줄 길이 제한 초과PEP8 가이드라인에 따라 줄 길이를 79자 이내로 수정해주세요.
- if score.m_count == m_count and score.b_match == b_match: + if (score.m_count == m_count and + score.b_match == b_match):src/lotto/main.py (2)
66-94
: 함수 분리 필요
print_result
함수가 너무 많은 책임을 가지고 있습니다. 다음과 같이 더 작은 함수들로 분리하는 것을 추천드립니다:
- 당첨 개수 계산
- 총 상금 계산
- 결과 출력
- 수익률 계산 및 출력
예시:
def calculate_win_counts(result_list): score_count = {score: 0 for score in Score if score != Score.NONE} for match_count, bonus_match in result_list: score = Score.get_score(match_count, bonus_match) if score != Score.NONE: score_count[score] += 1 return score_count def calculate_total_prize(score_count): return sum(score.prize * cnt for score, cnt in score_count.items()) def print_win_statistics(score_count): for score in Score: if score == Score.NONE: continue description = f"{score.m_count}개 일치" if score.b_match == 1: description += ", 보너스 볼 일치" print(f"{description} ({format(score.prize, ',d')}원)", f"- {score_count[score]}개") def print_revenue_rate(total_prize, purchase_amount): revenue_rate = (total_prize / purchase_amount) * 100 print(f"총 수익률은 {revenue_rate:.1f}%입니다.")🧰 Tools
🪛 GitHub Actions: Check Function Length
[warning] 66-66: Too many statements (16/15) (too-many-statements)
100-100
: 줄 길이 제한 초과PEP8 가이드라인에 따라 줄 길이를 79자 이내로 수정해주세요.
- issued_l_list = [Lotto.issuance_lotto() for _ in range(l_quantity)] + issued_l_list = [ + Lotto.issuance_lotto() for _ in range(l_quantity) + ]🧰 Tools
🪛 GitHub Actions: Check PEP8 Style
[error] 100-100: line too long (80 > 79 characters)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/lotto/lotto.py
(1 hunks)src/lotto/main.py
(1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/lotto/main.py
[warning] 20-20: src/lotto/main.py#L20
Added line #L20 was not covered by tests
[warning] 22-22: src/lotto/main.py#L22
Added line #L22 was not covered by tests
[warning] 45-46: src/lotto/main.py#L45-L46
Added lines #L45 - L46 were not covered by tests
src/lotto/lotto.py
[warning] 13-13: src/lotto/lotto.py#L13
Added line #L13 was not covered by tests
[warning] 44-44: src/lotto/lotto.py#L44
Added line #L44 was not covered by tests
[warning] 48-48: src/lotto/lotto.py#L48
Added line #L48 was not covered by tests
🪛 GitHub Actions: Check Function Length
src/lotto/main.py
[warning] 66-66: Too many statements (16/15) (too-many-statements)
🪛 GitHub Actions: Check PEP8 Style
src/lotto/main.py
[error] 100-100: line too long (80 > 79 characters)
🪛 GitHub Actions: Check No External Libraries
src/lotto/lotto.py
[error] 1-1: External library detected: typing in src/lotto/lotto.py
🔇 Additional comments (7)
src/lotto/lotto.py (4)
1-1
: 외부 라이브러리 사용 제한 위반
typing
모듈은 외부 라이브러리로 감지되었습니다. Python 3.9+ 내장 타입을 사용하도록 수정해주세요.-from typing import List
🧰 Tools
🪛 GitHub Actions: Check No External Libraries
[error] 1-1: External library detected: typing in src/lotto/lotto.py
6-7
: 매직 넘버 상수화 잘 되었습니다!로또 크기와 번호 범위를 상수로 정의한 것이 좋습니다.
16-19
: 인스턴스 변수 초기화 방식 수정 필요타입 힌트만 대입하고 실제 값을 설정하지 않아 의도대로 동작하지 않을 수 있습니다.
- self.bonus_number = int - self.numbers_list = List[list] - self.result_list = List[int] - self.statistics_list = List[list] + self.bonus_number: int = 0 + self.numbers_list: list[list] = [] + self.result_list: list[int] = [] + self.statistics_list: list[list] = []
75-81
: 상금 등급 구현이 잘 되었습니다!각 등수별 상금과 조건이 명확하게 정의되어 있습니다.
src/lotto/main.py (3)
34-34
: 함수 파라미터 오타 수정 필요
purcahse_amount
의 철자가 잘못되었습니다.-def generate_lotto_quantity(purcahse_amount): +def generate_lotto_quantity(purchase_amount):
16-23
: 구매 금액 검증 로직이 잘 구현되었습니다!양의 정수 확인과 1,000원 단위 검증이 잘 되어있습니다.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 20-20: src/lotto/main.py#L20
Added line #L20 was not covered by tests
[warning] 22-22: src/lotto/main.py#L22
Added line #L22 was not covered by tests
61-63
: 보너스 번호 변수명 오타 수정 필요'bouns_number'를 'bonus_number'로 수정해주세요.
- bouns_number = input() - bouns_number = is_number(bouns_number) - lotto.validate_bonus_number(bouns_number) + bonus_number = input() + bonus_number = is_number(bonus_number) + lotto.validate_bonus_number(bonus_number)
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.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/lotto/main.py (1)
58-64
:⚠️ Potential issue보너스 번호 입력 함수의 개선이 필요합니다.
- 'bouns_number'의 철자가 잘못되었습니다.
- 함수가 보너스 번호를 반환하지 않습니다.
def input_bonus_number(lotto): print("\n보너스 번호를 입력해 주세요.") - bouns_number = input() - bouns_number = is_number(bouns_number) - lotto.validate_bonus_number(bouns_number) + bonus_number = input() + bonus_number = is_number(bonus_number) + lotto.validate_bonus_number(bonus_number) + return bonus_number
🧹 Nitpick comments (6)
src/lotto/main.py (6)
1-5
: 불필요한 빈 줄을 제거해주세요.임포트 문과 상수 정의 사이의 빈 줄이 너무 많습니다. PEP 8 스타일 가이드에 따르면 두 줄 이상의 빈 줄은 피해야 합니다.
from lotto.lotto import Lotto from lotto.lotto import Score - - LOTTO_EACH_PRICE = 1000 # 로또 구입 금액 단위 매직넘버상수
40-47
: 에러 처리에 대한 테스트와 입력 검증이 필요합니다.
- 에러 케이스에 대한 테스트가 누락되어 있습니다.
- 입력 문자열의 공백 처리가 더 엄격해야 합니다.
def convert_to_list(data): try: - data = list(map(int, data.replace(" ", "").split(","))) + # 앞뒤 공백 제거 및 연속된 공백 처리 + data = list(map(int, data.strip().replace(" ", "").split(","))) + if not data: + raise ValueError("[ERROR] 빈 입력은 허용되지 않습니다.") return data except ValueError as e: raise ValueError("[ERROR] 번호는 정수로 이루어져 있어야 합니다.") from e🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 45-46: src/lotto/main.py#L45-L46
Added lines #L45 - L46 were not covered by tests
66-76
: 출력 포맷팅 개선이 필요합니다.긴 출력문을 여러 줄로 나누어 가독성을 높이는 것이 좋습니다.
- print(f"{description} ({format(score.prize, ',d')}원)", end="") - print(f" - {score_count[score]}개") + prize_str = format(score.prize, ',d') + count_str = score_count[score] + print( + f"{description} ({prize_str}원) - {count_str}개" + )
78-98
: 코드 포맷팅 문제를 수정해주세요.
- 89번 줄의 후행 공백을 제거해주세요.
- 96번 줄 이전의 불필요한 빈 줄을 제거해주세요.
if score != Score.NONE: score_count[score] += 1 - + just_print(Score, score_count) # 총 당첨 금액 계산 total_prize = sum(score.prize * cnt for score, cnt in score_count.items()) - - # 수익률 계산 및 출력🧰 Tools
🪛 GitHub Actions: Check Indentation Depth
[warning] 89-89: Trailing whitespace (trailing-whitespace)
🪛 GitHub Actions: Check PEP8 Style
[warning] 89-89: Blank line contains whitespace.
[error] 96-96: Too many blank lines (2).
101-116
: 주석의 오타를 수정해주세요.103번 줄의 주석에서 '계산산'을 '계산'으로 수정해주세요.
- l_quantity = generate_lotto_quantity(purchase_amount) # 로또 수량 계산산 + l_quantity = generate_lotto_quantity(purchase_amount) # 로또 수량 계산
105-108
: 변수명을 더 명확하게 개선해주세요.
issu_l_list
와l_quantity
와 같은 축약된 변수명은 가독성을 해칩니다. 더 명확한 이름을 사용해주세요.- l_quantity = generate_lotto_quantity(purchase_amount) - issu_l_list = [Lotto.issuance_lotto() for _ in range(l_quantity)] - for lotto in issu_l_list: + lotto_quantity = generate_lotto_quantity(purchase_amount) + issued_lotto_list = [Lotto.issuance_lotto() for _ in range(lotto_quantity)] + for lotto in issued_lotto_list:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lotto/main.py
(1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/lotto/main.py
[warning] 20-20: src/lotto/main.py#L20
Added line #L20 was not covered by tests
[warning] 22-22: src/lotto/main.py#L22
Added line #L22 was not covered by tests
[warning] 45-46: src/lotto/main.py#L45-L46
Added lines #L45 - L46 were not covered by tests
🪛 GitHub Actions: Check Indentation Depth
src/lotto/main.py
[warning] 89-89: Trailing whitespace (trailing-whitespace)
🪛 GitHub Actions: Check PEP8 Style
src/lotto/main.py
[warning] 89-89: Blank line contains whitespace.
[error] 96-96: Too many blank lines (2).
🔇 Additional comments (3)
src/lotto/main.py (3)
8-14
: 잘 구현된 입력 검증 함수입니다!정수 검증과 에러 처리가 명확하게 구현되어 있습니다.
16-24
: 에러 케이스에 대한 테스트 커버리지가 필요합니다.음수 입력과 1,000원 단위가 아닌 경우에 대한 테스트가 누락되어 있습니다.
테스트 케이스 예시:
def test_validate_purchase_amount_negative(): with pytest.raises(ValueError, match="구입 금액은 양의 정수 입니다."): validate_purchase_amount("-1000") def test_validate_purchase_amount_not_unit(): with pytest.raises(ValueError, match="구입 금액을 1,000원 단위로 입력해 주세요."): validate_purchase_amount("1500")🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 20-20: src/lotto/main.py#L20
Added line #L20 was not covered by tests
[warning] 22-22: src/lotto/main.py#L22
Added line #L22 was not covered by tests
33-38
: 매개변수 이름의 오타를 수정해주세요.
purcahse_amount
의 철자가 잘못되었습니다.purchase_amount
로 수정해주세요.-def generate_lotto_quantity(purcahse_amount): - lotto_quantity = purcahse_amount // LOTTO_EACH_PRICE +def generate_lotto_quantity(purchase_amount): + lotto_quantity = purchase_amount // LOTTO_EACH_PRICE
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.
Actionable comments posted: 1
🧹 Nitpick comments (6)
src/lotto/main.py (6)
8-14
: 예외 처리에 대한 테스트 케이스가 필요합니다.예외 상황에 대한 테스트 케이스를 추가하여 코드의 안정성을 높이는 것이 좋겠습니다.
테스트 케이스 작성을 도와드릴까요?
16-24
: 구매 금액 검증 로직에 대한 테스트가 필요합니다.다음 케이스들에 대한 테스트 코드가 누락되어 있습니다:
- 음수 금액 입력
- 1000원 단위가 아닌 금액 입력
누락된 테스트 케이스 작성을 도와드릴까요?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 20-20: src/lotto/main.py#L20
Added line #L20 was not covered by tests
[warning] 22-22: src/lotto/main.py#L22
Added line #L22 was not covered by tests
66-76
: 코드 가독성 개선이 필요합니다.긴 출력문을 여러 줄로 나누어 가독성을 높이는 것이 좋겠습니다.
- print(f"{description} ({format(score.prize, ',d')}원)", end="") - print(f" - {score_count[score]}개") + prize_str = format(score.prize, ',d') + count_str = score_count[score] + print( + f"{description} ({prize_str}원) - {count_str}개" + )
78-98
: 변수명과 주석을 더 명확하게 개선할 수 있습니다.
cnt
와 같은 축약된 변수명을 피하고count
와 같이 명확한 이름을 사용하세요.- 복잡한 계산 로직에 대한 설명 주석을 추가하세요.
- total_prize = sum(score.prize * cnt for score, cnt in score_count.items()) + # 각 등수별 상금과 당첨 횟수를 곱하여 총 상금 계산 + total_prize = sum( + score.prize * count + for score, count in score_count.items() + )
100-115
: 변수명을 더 명확하게 개선해주세요.
l_quantity
,issu_l_list
와 같은 축약된 변수명을 아래와 같이 더 명확한 이름으로 변경하는 것이 좋겠습니다.- l_quantity = generate_lotto_quantity(purchase_amount) - issu_l_list = [Lotto.issuance_lotto() for _ in range(l_quantity)] - for lotto in issu_l_list: + lotto_quantity = generate_lotto_quantity(purchase_amount) + issued_lotto_list = [Lotto.issuance_lotto() for _ in range(lotto_quantity)] + for lotto in issued_lotto_list:
1-119
: 전반적인 테스트 커버리지 개선이 필요합니다.다음 영역들에 대한 테스트 케이스 추가를 권장합니다:
- 입력값 검증 함수들의 예외 처리
- 구매 금액 검증
- 당첨 번호와 보너스 번호 입력 처리
테스트 케이스 작성 방법에 대해 도움이 필요하시다면 말씀해 주세요.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 20-20: src/lotto/main.py#L20
Added line #L20 was not covered by tests
[warning] 22-22: src/lotto/main.py#L22
Added line #L22 was not covered by tests
[warning] 45-46: src/lotto/main.py#L45-L46
Added lines #L45 - L46 were not covered by tests
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lotto/main.py
(1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/lotto/main.py
[warning] 20-20: src/lotto/main.py#L20
Added line #L20 was not covered by tests
[warning] 22-22: src/lotto/main.py#L22
Added line #L22 was not covered by tests
[warning] 45-46: src/lotto/main.py#L45-L46
Added lines #L45 - L46 were not covered by tests
🔇 Additional comments (3)
src/lotto/main.py (3)
1-5
: 잘 정의된 상수와 임포트문입니다!매직 넘버를 상수로 분리하여 관리하는 것이 좋은 방법입니다.
33-38
: 매개변수 이름에 오타가 있습니다.
purcahse_amount
를purchase_amount
로 수정해주세요.-def generate_lotto_quantity(purcahse_amount): - lotto_quantity = purcahse_amount // LOTTO_EACH_PRICE +def generate_lotto_quantity(purchase_amount): + lotto_quantity = purchase_amount // LOTTO_EACH_PRICE
58-64
: 변수 이름에 오타가 있습니다.
bouns_number
를bonus_number
로 수정해주세요.- bouns_number = input() - bouns_number = is_number(bouns_number) - lotto.validate_bonus_number(bouns_number) + bonus_number = input() + bonus_number = is_number(bonus_number) + lotto.validate_bonus_number(bonus_number)
# 입력 값을 list 형식으로 변환해주는 함수 | ||
def convert_to_list(data): | ||
try: | ||
data = list(map(int, data.replace(" ", "").split(","))) | ||
return data | ||
except ValueError as e: | ||
raise ValueError("[ERROR] 번호는 정수로 이루어져 있어야 합니다.") from e | ||
|
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.
🛠️ Refactor suggestion
입력값 검증 강화 및 테스트 추가가 필요합니다.
- 예외 처리 로직에 대한 테스트가 누락되어 있습니다.
- 입력값이 비어있는 경우에 대한 처리가 필요합니다.
def convert_to_list(data):
try:
+ if not data.strip():
+ raise ValueError("[ERROR] 빈 입력값은 허용되지 않습니다.")
data = list(map(int, data.replace(" ", "").split(",")))
return data
except ValueError as e:
raise ValueError("[ERROR] 번호는 정수로 이루어져 있어야 합니다.") from e
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# 입력 값을 list 형식으로 변환해주는 함수 | |
def convert_to_list(data): | |
try: | |
data = list(map(int, data.replace(" ", "").split(","))) | |
return data | |
except ValueError as e: | |
raise ValueError("[ERROR] 번호는 정수로 이루어져 있어야 합니다.") from e | |
# 입력 값을 list 형식으로 변환해주는 함수 | |
def convert_to_list(data): | |
try: | |
if not data.strip(): | |
raise ValueError("[ERROR] 빈 입력값은 허용되지 않습니다.") | |
data = list(map(int, data.replace(" ", "").split(","))) | |
return data | |
except ValueError as e: | |
raise ValueError("[ERROR] 번호는 정수로 이루어져 있어야 합니다.") from e |
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 45-46: src/lotto/main.py#L45-L46
Added lines #L45 - L46 were not covered by tests
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/lotto/lotto.py (1)
35-71
: 테스트 커버리지 개선 필요다음 메서드들에 대한 테스트 케이스가 누락되었습니다:
issuance_lotto()
__str__()
get_numbers()
각 메서드의 정상 동작을 검증하는 단위 테스트를 추가해주세요.
테스트 케이스 작성을 도와드릴까요?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 43-43: src/lotto/lotto.py#L43
Added line #L43 was not covered by tests
[warning] 47-47: src/lotto/lotto.py#L47
Added line #L47 was not covered by tests
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lotto/lotto.py
(1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/lotto/lotto.py
[warning] 12-12: src/lotto/lotto.py#L12
Added line #L12 was not covered by tests
[warning] 43-43: src/lotto/lotto.py#L43
Added line #L43 was not covered by tests
[warning] 47-47: src/lotto/lotto.py#L47
Added line #L47 was not covered by tests
🔇 Additional comments (4)
src/lotto/lotto.py (4)
1-7
: 상수 정의와 임포트가 잘 구현되었습니다!매직 넘버를 상수로 적절히 추출하고 한글 주석으로 문서화한 점이 좋습니다.
15-18
: 인스턴스 변수 초기화 방식 수정 필요타입 힌트만 대입하는 대신 실제 초기값을 설정해야 합니다:
- self.bonus_number = int - self.numbers_list = list[list] - self.result_list = list[int] - self.statistics_list = list[list] + self.bonus_number: int = 0 + self.numbers_list: list[list] = [] + self.result_list: list[int] = [] + self.statistics_list: list[list] = []
20-33
: 검증 로직이 잘 구현되었습니다!번호 길이, 범위, 중복 검사 및 보너스 번호 검증이 상세한 에러 메시지와 함께 잘 구현되었습니다.
92-94
: 줄 길이 제한 초과93번 줄이 PEP8 줄 길이 제한(79자)을 초과했습니다. 다음과 같이 수정해주세요:
- if score.m_count == m_count and score.b_match == b_match: + if (score.m_count == m_count and + score.b_match == b_match):
Summary by CodeRabbit