-
Notifications
You must be signed in to change notification settings - Fork 94
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
#403: add a feature to download MatchOverview of Topcoder Marathon Match #406
Conversation
onlinejudge/service/topcoder.py
Outdated
submissions += [TopcoderLongContestProblemIndividualResultsFeedSubmission(number, score, language, time)] | ||
testcases = [] # type: List[TopcoderLongContestProblemIndividualResultsFeedTestCase] | ||
for testcase in list(root)[4]: | ||
test_case_id = int(list(testcase)[0].text or '') |
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.
この(or '')ってなんでしょう?int('')だと例外発生します。
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.
mypy を黙らせるための処理です。例外はむしろ発生するのが適切です。
ちょっと上で次のようにコメントしてるのと同じものです。
選択肢はいくつかありますが、まず # type: ignore
を付けると行全体が無効化されてしまうのでだめ、次に
x = list(testcase)[0]
if x is None:
raise RuntimeError
test_case_id = int(x)
は長すぎてこれもだめ。
次のような関数を定義することもできますが、
def unwrap(s: Optional[str]) -> str:
これを定義するのと次のようにコメントで示すのはあまり差がないと思ったのですが、そうではなかったですか?
きれいに解決できる方法を見付けたのでそうしました |
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.
LGTM
close #403
かなりそのままな形で実装しました。
cr
rd
のような妙な名前は Topcoder 側のしている省略に合わせています。型名がすごく長いですが、短くするよりましだと思ったのでこうなってます。