-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from kd-it/main
merge code
- Loading branch information
Showing
16 changed files
with
226 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,46 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
"name": "Ubuntu", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/base:jammy", | ||
"features": { | ||
"ghcr.io/devcontainers/features/github-cli:1": {} | ||
} | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "uname -a", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/python | ||
{ | ||
"name": "Python環境", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", | ||
"features": { | ||
"ghcr.io/devcontainers/features/github-cli:1": { | ||
"installDirectlyFromGitHubRelease": true, | ||
"version": "latest" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.black-formatter", | ||
"esbenp.prettier-vscode", | ||
"oderwat.indent-rainbow" | ||
], | ||
"settings": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"python.defaultInterpreterPath": "/usr/local/bin/python", | ||
"editor.formatOnSave": true, | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "pip3 install --user -r requirements.txt", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
on: | ||
push: | ||
paths: "lesson01/*.py" | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
# code check | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python(3.12) | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install black formatter | ||
run: pip install black | ||
|
||
# コードをフォーマットするが、結果は別の場所に保存する | ||
- name: check formatting | ||
run: black lesson01/ --check --diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
push: | ||
paths: "lesson02/*.py" | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
# code check | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python(3.12) | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: code check in lesson02 | ||
run: | | ||
cd lesson02 | ||
python typecheck01.py | ||
- name: code check in lesson02(is_int_list) | ||
if: always() | ||
run: | | ||
cd lesson02 | ||
python typecheck02.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
push: | ||
paths: "lesson03/*.py" | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
# code check | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python(3.12) | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: code check in lesson03(01) | ||
run: | | ||
cd lesson03 | ||
python test_01.py | ||
- name: code check in lesson03(02) | ||
if: always() | ||
run: | | ||
cd lesson03 | ||
python test_02.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
__pycache__/ | ||
**/__pycache__/ | ||
.vscode/settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
# GitHubセミナー 2024年度版 | ||
# Python セミナー その 2 2024 年度版 | ||
|
||
## 何をするの? | ||
|
||
GitHubの使い方についての簡単なセミナーです。 | ||
ざっくり以下のことを行う予定です。 | ||
Python を通して、各言語における比較的共通性のある話題を意識し直してもらいます。 | ||
|
||
- GitHubの使い方、見方(サイト上) | ||
- GitHubコマンド(`gh`) | ||
- GitHubでのリポジトリ操作 | ||
- 自力編 | ||
- チーム編 | ||
- コンフリクト編 | ||
- プルリクエスト編 | ||
- おまけ機能紹介(時間のある範囲で) | ||
- GitHub Actions | ||
- GitHub Pages | ||
## 主な議題 | ||
|
||
## 使い方 | ||
- コードを少しきれいに書く | ||
- 型の制約で安心感を少しあげる | ||
- テストを書く | ||
- ドキュメントを書く | ||
|
||
このリポジトリは直接クローンせず、必ずフォーク(fork)してからそちらをクローンしてください。 | ||
詳細はセミナーで説明します。 | ||
|
||
(forkしたリポジトリから)ローカルに構築できたら、DevContainerを起動してください。 | ||
おまけはいくつかあるかな |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# このファイルは意図的に空っぽにしています | ||
# ちょっときたな目にコードを書いて保存してみましょう | ||
# 例: x=42 | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 型のミスマッチが起こすバグの例 | ||
|
||
|
||
def add_one(): | ||
pass | ||
|
||
|
||
def is_int_list(): | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
pass # ここに上記関数を使うコードを書いてみる | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env python3 | ||
# 注意: このファイルはいじらないでください | ||
|
||
import typing | ||
from missmatch import add_one | ||
|
||
assert typing.get_type_hints(add_one)["x"] == int, "引数xの型ヒントがintではありません" | ||
assert ( | ||
typing.get_type_hints(add_one)["return"] == int | ||
), "戻り値の型ヒントがintではありません" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env python3 | ||
# 注意: このファイルはいじらないでください | ||
|
||
import typing | ||
from missmatch import is_int_list | ||
|
||
# is_int_list()の型ヒントを確認する | ||
assert ( | ||
typing.get_type_hints(is_int_list)["lst"] == list[any] | ||
), "引数lstの型ヒントがlist[any]ではありません" | ||
# is_int_list()の戻り値がboolであることを確認する | ||
assert ( | ||
typing.get_type_hints(is_int_list)["return"] == bool | ||
), "戻り値の型ヒントがboolではありません" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# assertを使ったテストコードの例 | ||
|
||
|
||
# 引数で渡された値が奇数であるかどうかを返す関数 | ||
# 型ヒントにより 整数→bool となるようにしましょう | ||
def is_odd(): | ||
pass | ||
|
||
|
||
# 直接実行時に、上記関数が正常に機能するかをassert文で書いてみましょう | ||
# 全てが正常に機能したら"All tests passed!"と表示しましょう |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# doctestの練習(テストケース) | ||
# 関数is_leap_yearを考えてみましょう | ||
# この関数は、引数で受け取った年がうるう年かどうかを判定する関数です | ||
# うるう年の条件は以下の通りです | ||
# 1. 西暦が4で割り切れる年はうるう年 | ||
# 2. ただし、西暦が100で割り切れる年はうるう年ではない | ||
# 3. ただし、西暦が400で割り切れる年はうるう年 | ||
|
||
|
||
def is_leap_year(year: int) -> bool: | ||
if year % 4 == 0: | ||
if year % 100 == 0: | ||
if year % 400 == 0: | ||
return True | ||
else: | ||
return False | ||
return True | ||
return False | ||
|
||
|
||
# いわゆるFizzBuzz問題 | ||
# 指定された数値までの数値の結果をリストで返しましょう | ||
# ルール: 3の倍数は'fuzz'、5の倍数は'buzz'、3と5の倍数は'fizzbuzz'とする | ||
# それ以外の値は数値を文字列にして返す(list[str]となる) | ||
# fb_list(5) -> ['1', '2', 'fizz', '4', 'buzz'] | ||
|
||
|
||
def fb_list(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from test_01 import is_odd | ||
|
||
# 実際に1〜10に対するis_oddの結果を出すように書いてみましょう |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.