-
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
support python3.5 #218
support python3.5 #218
Conversation
masterブランチでも型アノテーション関連のwarningが出ている気がします。大丈夫でしょうか? |
ありがとうございます。 しかしこれをそのままではmergeできないのでいくつか修正をお願いします。 まず型アノテーションの書き方が間違っています。 他の細かい指摘はレビュー機能で書いたので見ておいてください。 mypy ログ$ mypy --ignore-missing-imports oj
onlinejudge/dispatch.py:9: error: Need type annotation for 'submissions'
onlinejudge/dispatch.py:19: error: Need type annotation for 'problems'
onlinejudge/dispatch.py:32: error: Need type annotation for 'services'
onlinejudge/implementation/utils.py:103: error: Need type annotation for 'payload'
onlinejudge/implementation/utils.py:104: error: Need type annotation for 'files'
onlinejudge/topcoder.py:168: error: Need type annotation for 'rows'
onlinejudge/topcoder.py:182: error: Need type annotation for 'row'
onlinejudge/aoj.py:57: error: Need type annotation for 'samples'
onlinejudge/aoj.py:75: error: Need type annotation for 'testcases'
onlinejudge/yukicoder.py:222: error: Need type annotation for 'data'
onlinejudge/yukicoder.py:268: error: Need type annotation for 'basenames'
onlinejudge/yukicoder.py:279: error: Need type annotation for 'samples'
onlinejudge/atcoder.py:288: error: Incompatible types in assignment (expression has type "int", variable has type "None")
onlinejudge/atcoder.py:289: error: Incompatible return value type (got "None", expected "int")
onlinejudge/implementation/command/utils.py:42: error: Need type annotation for 'result'
onlinejudge/implementation/command/utils.py:51: error: Need type annotation for 'tests'
onlinejudge/implementation/command/generate_scanner.py:22: error: Need type annotation for 'tokens'
onlinejudge/implementation/command/generate_scanner.py:48: error: Need type annotation for 'env'
onlinejudge/implementation/command/generate_scanner.py:61: error: Need type annotation for 'used'
onlinejudge/implementation/command/generate_scanner.py:80: error: Need type annotation for 'names'
onlinejudge/implementation/command/generate_scanner.py:92: error: Need type annotation for 'body'
onlinejudge/implementation/command/generate_scanner.py:192: error: Incompatible types in assignment (expression has type "List[List[Dict[str, str]]]", variable has type "Optional[str]")
onlinejudge/implementation/command/generate_scanner.py:194: error: Incompatible types in assignment (expression has type "List[Dict[str, Any]]", variable has type "Optional[str]")
onlinejudge/implementation/command/generate_scanner.py:194: error: Argument 1 to "parse" has incompatible type "str"; expected "List[List[Dict[str, Any]]]"
onlinejudge/implementation/command/submit.py:66: error: Incompatible types in assignment (expression has type "None", variable has type "List[Any]")
onlinejudge/implementation/command/submit.py:272: error: Value of type "object" is not indexable
onlinejudge/implementation/command/submit.py:273: error: Value of type "object" is not indexable
onlinejudge/implementation/command/submit.py:274: error: "object" has no attribute "get"
onlinejudge/implementation/command/test.py:82: error: Incompatible types in assignment (expression has type "float", variable has type "int") |
tests/download.py
Outdated
@@ -31,9 +31,10 @@ def snippet_call_download(self, url, files, is_system=False, type='files'): | |||
os.chdir(tempdir) | |||
if os.path.exists('test'): | |||
shutil.rmtree('test') | |||
cmd = [ ojtools, 'download', url ] | |||
cmd = [ ojtools, 'download' ] |
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.
以前の形でも動いているのなら無闇に変更箇所を増やさないでほしいですし、何か問題があったのなら黙って修正するのでなく別のコミットに分けてコメントを付けてほしいです。
.travis.yml
Outdated
only: | ||
- master | ||
- develop | ||
|
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.
消さないでほしいです。
CIから外部のサービスへアクセスをかける性質によりすべてのコミットごとにCIを走らせるのは適切ではないです。
onlinejudge/aoj.py
Outdated
samples: List[TestCase] = [] | ||
for sample in json.loads(resp.content): | ||
samples = [] # List[TestCase] | ||
for sample in json.loads(resp.content.decode('utf-8')): |
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.
for sample in json.loads(resp.content.decode('utf-8')): | |
for sample in json.loads(resp.content.decode(resp.encoding)): |
たぶんこの方が適切です
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.
他の2箇所も同様にお願いします
match.__getitem__ is supported python >3.6
🎉 |
いろいろと不手際ありすいません。丁寧にレビューしてもらい勉強になりました。 また、re.matchオブジェクトのインデクシングは(m[0])Python3.6以降でしかサポートされてないのですが、 |
いいえ、最初から完璧というのはありえないですし気にすることではありません。 また、この修正を反映させた版をuploadしました。pipで更新すれば動くようになると思います。 |
とりあえずテストは通しました。手元ではatcoderだけ軽く試しています。
jsonはdecode('UTF-8')すればいけたのと、Python3.5のargparseは--systemが最後のコマンドライン引数だとエラーになりましたので修正しました。
ついでにbranch名に限らずテストされるようにしました。
Python3.5対応するかどうかはお任せします。(個人的には嬉しいですが、3.6しかやらんぞというのもまた決断)
型アノテーションの書き方はPython3.6で書かれている書き方のほうがわかりやすいですね。