Skip to content

Commit 4d7ff4a

Browse files
authored
Merge pull request #109 from yupix/develop
release v0.6.0
2 parents 7ccf797 + 749a519 commit 4d7ff4a

File tree

187 files changed

+53544
-61282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+53544
-61282
lines changed

.github/CONTRIBUTING.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@ Check the going points before creating an assignment
1717
- `develop` is the branch to work on for the next release
1818
- If you want to create a pull request, please send it to this branch
1919

20+
## Building a Development Environment
21+
22+
```
23+
python -m venv .venv
24+
25+
# after activate env
26+
27+
pip install -r requirements.txt -r requirements-dev.txt
28+
29+
pre-commit install
30+
```
31+
2032
## Creating a pull request
2133

2234
- Create an Issue before creating a pull request.
23-
- Please prefix the branch name with a keyword such as `feat` / `fix` / `refactor` / `chore` to identify the pull request as much as possible.
35+
- Please prefix the branch name with a keyword such as `feat` / `fix` / `refactor` / `chore` to identify the pull request as much as possible.
2436
- Also, do not include changes other than to resolve the pull request issue
2537
- If you have an Issue that will be resolved by a pull request, please include a link
2638
- Any changes should be described in `CHANGELOG.md`. However, if there is no change from the user's point of view, there is no need to describe it.
@@ -38,3 +50,42 @@ This project uses `axblack` and `isort` formatting. The difference between `axbl
3850

3951
- Ayuskey v5, 6
4052
- Misskey v13, 12, 11
53+
54+
### 引数に関する例外について
55+
56+
Misskey側に渡すBodyにおいて、例えば `limit` に渡せる最大数が100だと分かっていても、MiPAC側で特別なことはしないものとする。これはAPIを叩いた際に帰ってくるエラーをより直接的に見れるようにするためです
57+
58+
### 引数のデフォルト値について
59+
60+
少し複雑な話になる為例を出しつつの説明になります。
61+
例として `/api/channels/update` には `isSensitive``bannerId` といったキーを渡すことができます。では `update` メソッドを実際に作ってみましょう。
62+
63+
```python
64+
async def update(
65+
self,
66+
banner_id: str | None = None,
67+
is_sensitive: bool | None = None,
68+
) -> :
69+
...
70+
```
71+
72+
まず、 `is_sensitive``None` が選べてしまうのは何か気持ち悪い所があります。次に`banner_id` は エンドポイント側がnullを許容している為、既に `banner_id` が設定してあった場合、`is_sensitive` のみを更新しようとした場合にnullに設定されてしまいます。また、`request` メソッドが持つ `remove_none=True` でNoneを消すことができますが、これでは `banner_id` を nullにする方法がなくなってしまします。
73+
74+
では、ここで`MISSING` を使って書き直します。
75+
76+
```python
77+
async def update(
78+
self,
79+
banner_id: str | None = MISSING,
80+
is_sensitive: bool = MISSING,
81+
) -> :
82+
data = remove_dict_missing({
83+
"bannerId": banner_id,
84+
"isSensitive": is_sensitive
85+
})
86+
self._session.request(Route("POST", "/api/channels/update"), auth=True, json=data, remove_none=False)
87+
...
88+
```
89+
90+
`is_sensitive` のTypeHintsが `bool` のみにできるので気持ち悪さが解消されます。
91+
また、 `remove_dict_missing` を使用することで `MISSING` のみを削除出来るため、Noneに設定したい場合は `await update(banner_id=None)` とすることで `banner_id` を null に設定できるようになります。注意点として、 `request` メソッドの `remove_none=False` に設定しないと `None` が削除されてしまうため気を付けてください。基本的に `/api/channels/create` のように作成系等では既にサーバー上にあるデータに留意する必要が無いため、`MISSING` ではなく `None` を使用しても問題ないです
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: ✨ Support new endpoint request
3+
about: Suggest an idea
4+
title: ''
5+
labels: kind/Feature✨, topic/API🧩, Actions⚙, Manager📦
6+
assignees: yupix
7+
8+
---
9+
10+
## Summary
11+
12+
<!-- Tell us what the suggestion is -->
13+
14+
## Work
15+
16+
- [ ] v11 support
17+
- [ ] v12 support
18+
- [ ] v13 support
19+
20+

.github/workflows/code_quality.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Qodana
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches: "**"
7+
8+
9+
jobs:
10+
qodana:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
checks: write
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
20+
fetch-depth: 0 # a full history is required for pull request analysis
21+
- name: 'Qodana Scan'
22+
uses: JetBrains/qodana-action@v2023.3
23+
env:
24+
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

.github/workflows/doc_build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Document Release
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
7+
jobs:
8+
release:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: [3.12]
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
submodules: true
19+
20+
- name: Setup Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install Package
26+
run: |
27+
pip install -e .[doc]
28+
29+
- name: Build Docs
30+
run: python doc_gen.py
31+
32+
- name: Deploy
33+
uses: peaceiris/actions-gh-pages@v3
34+
with:
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
publish_dir: ./docs/_build/html
37+
cname: mipac.akarinext.org

.github/workflows/python-app.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,25 @@ on:
77
push:
88
branches: "**"
99
pull_request:
10-
branches: [ "master" ]
10+
branches: ["master"]
1111

1212
permissions:
1313
contents: read
1414

1515
jobs:
1616
type-check:
17-
1817
runs-on: ubuntu-latest
1918

2019
steps:
21-
- uses: actions/checkout@v3
22-
- name: Set up Python 3.11
23-
uses: actions/setup-python@v3
24-
with:
25-
python-version: "3.11"
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install . .[ci]
30-
- name: Lint with flake8
31-
run: |
32-
flake8 mipac
20+
- uses: actions/checkout@v3
21+
- name: Set up Python 3.12
22+
uses: actions/setup-python@v3
23+
with:
24+
python-version: "3.12"
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install . .[ci]
29+
- name: Lint with ruff
30+
run: |
31+
ruff check mipac

.github/workflows/python-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Python
2626
uses: actions/setup-python@v3
2727
with:
28-
python-version: '3.11'
28+
python-version: '3.12'
2929
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ __pycache__
55
build
66
dist
77
.idea
8-
docs/_build
8+
docs/_build
9+
.env

.onedev-buildspec.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
version: 26
2+
jobs:
3+
- name: Publish Packages(OneDev)
4+
steps:
5+
- !CheckoutStep
6+
name: checkout
7+
cloneCredential: !DefaultCredential {}
8+
withLfs: false
9+
withSubmodules: false
10+
cloneDepth: 2000
11+
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
12+
- !CommandStep
13+
name: publish artifact
14+
runInContainer: true
15+
image: python:3.12.2-slim
16+
interpreter: !DefaultInterpreter
17+
commands:
18+
- apt update
19+
- apt install -y git
20+
- ''
21+
- git fetch
22+
- ''
23+
- cat << EOF > $HOME/.pypirc
24+
- '[distutils]'
25+
- index-servers=
26+
- ' onedev'
27+
- ''
28+
- '[onedev]'
29+
- repository=https://onedev.akarinext.org/yupix/mipac-sync/MiPAC/~pypi
30+
- username=@job_token@
31+
- password=@secret:access-token@
32+
- EOF
33+
- ''
34+
- python -m pip install --upgrade pip
35+
- pip install build twine
36+
- ''
37+
- python -m build
38+
- ''
39+
- twine upload --repository onedev dist/*
40+
useTTY: true
41+
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
42+
triggers:
43+
- !BranchUpdateTrigger {}
44+
retryCondition: never
45+
maxRetries: 3
46+
retryDelay: 30
47+
timeout: 3600
48+
- name: Sync
49+
steps:
50+
- !PushRepository
51+
name: Push GitLab
52+
remoteUrl: https://lab.teamblackcrystal.com/yupix/MiPAC
53+
userName: yupix
54+
passwordSecret: gitlab-access-token
55+
force: true
56+
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
57+
triggers:
58+
- !BranchUpdateTrigger {}
59+
retryCondition: never
60+
maxRetries: 3
61+
retryDelay: 30
62+
timeout: 3600

.pre-commit-config.yaml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
4-
- repo: https://github.com/pycqa/isort
5-
rev: 5.10.1
6-
hooks:
7-
- id: isort
8-
- repo: https://github.com/axiros/axblack
9-
rev: 5f011e46362b8680d686cb7918e849e4cb17e826
10-
hooks:
11-
- id: black
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.2.2
13+
hooks:
14+
- id: ruff
15+
args: [ --fix ]
16+
- id: ruff-format
17+
- repo: https://github.com/RobertCraigie/pyright-python
18+
rev: v1.1.351
19+
hooks:
20+
- id: pyright

0 commit comments

Comments
 (0)