Skip to content

Commit b620fcd

Browse files
committed
Merge branch 'fix/client-run' of https://github.com/DA-344/pycord into fix/client-run
2 parents a81fe27 + 015bc45 commit b620fcd

File tree

11 files changed

+288
-53
lines changed

11 files changed

+288
-53
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* @Pycord-Development/maintainers
1+
* @Pycord-Development/library-maintainers @Pycord-Development/library-contributors
22

33
/discord/ @Pycord-Development/maintain-discord-api
44

.github/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Version | Supported |
66
| ------- | ------------------ |
77
| 2.x | :white_check_mark: |
8-
| <2.0.0 | :x: |
8+
| <2.6.1 | :x: |
99

1010
## Reporting a Vulnerability
1111

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docs JSON Export
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
export-docs-json:
11+
name: Export docs.json
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
id: checkout
16+
uses: actions/checkout@v5
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
id: setup-python
20+
with:
21+
python-version: "3.13"
22+
cache: "pip"
23+
cache-dependency-path: "requirements/docs.txt"
24+
check-latest: true
25+
- name: Install dependencies
26+
id: install-deps
27+
run: |
28+
python -m pip install -U pip
29+
pip install ".[docs]"
30+
pip install beautifulsoup4
31+
- name: Build Sphinx HTML docs
32+
id: build-sphinx
33+
run: sphinx-build -b html docs docs/_build/html
34+
- name: Export docs.json
35+
id: generate-json
36+
run: python scripts/docs_json_exporter.py
37+
- name: Upload docs.json as artifact
38+
uses: actions/[email protected]
39+
id: artifact-upload
40+
with:
41+
name: Pycord Docs JSON
42+
path: docs.json
43+
retention-days: 1
44+
- name: Show docs.json summary
45+
run: |
46+
head -n 40 docs.json || tail -n 40 docs.json
47+
- name: Output artifact ID
48+
run: |
49+
echo "artifact-id=${{ steps.artifact-upload.outputs.artifact-id }}" >> $GITHUB_OUTPUT
50+
echo "artifact-url=${{ steps.artifact-upload.outputs.artifact-url }}" >> $GITHUB_OUTPUT
51+
echo "::notice::Artifact uploaded: ${{ steps.artifact-upload.outputs.artifact-url }}"

.github/workflows/release.yml

Lines changed: 83 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,63 @@ jobs:
4141
env:
4242
VERSION: ${{ github.event.inputs.version }}
4343
run: |
44-
# PEP 440 version regex
4544
VALID_VERSION_REGEX='^([0-9]+\.[0-9]+\.[0-9]+((a|b|rc|\.dev|\.post)[0-9]+)?)$'
4645
if ! [[ $VERSION =~ $VALID_VERSION_REGEX ]]; then
4746
echo "::error::Invalid version string '$VERSION'. Must match PEP 440 (e.g. 1.2.0, 1.2.0rc1, 1.2.0.dev1, 1.2.0a1, 1.2.0b1, 1.2.0.post1)"
4847
exit 1
4948
fi
49+
if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+rc[0-9]+$ ]]; then
50+
echo "::error::Unsupported version string '$VERSION'. Only normal releases (e.g. 1.2.3) and rc (e.g. 1.2.3rc1) are supported at this time."
51+
exit 1
52+
fi
5053
echo "version=$VERSION" >> $GITHUB_OUTPUT
5154
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^)
5255
echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
53-
if [[ $VERSION =~ rc[0-9]+$ ]]; then
54-
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
55-
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
56+
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
57+
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
58+
if [[ $VERSION == *rc* ]]; then
5659
echo "is_rc=true" >> $GITHUB_OUTPUT
57-
elif [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
58-
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
59-
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
60-
echo "is_rc=false" >> $GITHUB_OUTPUT
6160
else
62-
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
63-
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
6461
echo "is_rc=false" >> $GITHUB_OUTPUT
6562
fi
6663
64+
branch_protection_rename:
65+
needs: [safety_check]
66+
runs-on: ubuntu-latest
67+
environment: release
68+
env:
69+
GH_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
70+
outputs:
71+
master_rule_id: ${{ steps.get_rule_ids.outputs.master_rule_id }}
72+
master_pattern: ${{ steps.get_rule_ids.outputs.master_pattern }}
73+
v_rule_id: ${{ steps.get_rule_ids.outputs.v_rule_id }}
74+
v_pattern: ${{ steps.get_rule_ids.outputs.v_pattern }}
75+
steps:
76+
- name: Get branch protection rule IDs
77+
id: get_rule_ids
78+
run: |
79+
gh api repos/${{ github.repository }}/branch-protection-rules > rules.json
80+
MASTER_ID=$(jq -r '.[] | select(.pattern == "master") | .id' rules.json)
81+
MASTER_PATTERN=$(jq -r '.[] | select(.pattern == "master") | .pattern' rules.json)
82+
V_ID=$(jq -r '.[] | select(.pattern | test("^v[0-9]+\\.[0-9]+\\.x$")) | .id' rules.json)
83+
V_PATTERN=$(jq -r '.[] | select(.pattern | test("^v[0-9]+\\.[0-9]+\\.x$")) | .pattern' rules.json)
84+
echo "master_rule_id=$MASTER_ID" >> $GITHUB_OUTPUT
85+
echo "master_pattern=$MASTER_PATTERN" >> $GITHUB_OUTPUT
86+
echo "v_rule_id=$V_ID" >> $GITHUB_OUTPUT
87+
echo "v_pattern=$V_PATTERN" >> $GITHUB_OUTPUT
88+
- name: Rename master protection to temp-master
89+
if: ${{ steps.get_rule_ids.outputs.master_rule_id != '' }}
90+
run: |
91+
gh api repos/${{ github.repository }}/branch-protection-rules/${{ steps.get_rule_ids.outputs.master_rule_id }} \
92+
-X PATCH -F pattern="temp-master"
93+
- name: Rename v*.* protection to temp-v
94+
if: ${{ steps.get_rule_ids.outputs.v_rule_id != '' }}
95+
run: |
96+
gh api repos/${{ github.repository }}/branch-protection-rules/${{ steps.get_rule_ids.outputs.v_rule_id }} \
97+
-X PATCH -F pattern="temp-v"
98+
6799
lib_release:
68-
needs: [safety_check,pre_config]
100+
needs: [pre_config, branch_protection_rename]
69101
runs-on: ubuntu-latest
70102
environment: release
71103
env:
@@ -119,7 +151,7 @@ jobs:
119151
DATE=$(date +'%Y-%m-%d')
120152
sed -i "/These changes are available on the \`.*\` branch, but have not yet been released\./{N;d;}" CHANGELOG.md
121153
sed -i "s/## \[Unreleased\]/## [$VERSION] - $DATE/" CHANGELOG.md
122-
sed -i "0,/## \[$VERSION\]/ s|## \[$VERSION\]|## [Unreleased]\n\nThese changes are available on the \`$BRANCH\` branch, but have not yet been released.\n\n### Added\n\n### Changed\n\n### Fixed\n\n### Removed\n\n&|" CHANGELOG.md
154+
sed -i "0,/## \[$VERSION\]/ s|## \[$VERSION\]|## [Unreleased]\n\nThese changes are available on the \`$BRANCH\` branch, but have not yet been released.\n\n### Added\n\n### Changed\n\n### Fixed\n\n### Deprecated\n\n### Removed\n\n&|" CHANGELOG.md
123155
sed -i "s|\[unreleased\]:.*|[unreleased]: https://github.com/$REPOSITORY/compare/v$VERSION...HEAD\n[$VERSION]: https://github.com/$REPOSITORY/compare/$(git describe --tags --abbrev=0 @^)...v$VERSION|" CHANGELOG.md
124156
git add CHANGELOG.md
125157
git commit -m "chore(release): update CHANGELOG.md for version $VERSION"
@@ -193,14 +225,15 @@ jobs:
193225
attestations: false
194226
verify-metadata: false
195227

196-
197228
- name: "Echo release url"
198229
run: echo "${{ steps.gh-release.outputs.url }}"
199230

200231
docs_release:
201232
runs-on: ubuntu-latest
202-
needs: [lib_release,pre_config]
203-
if: ${{ needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '0rc1')) }}
233+
needs: [lib_release, pre_config]
234+
if:
235+
${{ needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc
236+
== 'true' && endsWith(needs.pre_config.outputs.version, '0rc1')) }}
204237
environment: release
205238
steps:
206239
- name: "Sync Versions on Read the Docs"
@@ -213,6 +246,7 @@ jobs:
213246
run: |
214247
VERSION=${{ needs.pre_config.outputs.version }}
215248
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
249+
HIDDEN=$([[ $VERSION == *rc* ]] && echo true || echo false)
216250
if [[ $VERSION == *rc* ]]; then
217251
DOCS_VERSION="v${MAJOR_MINOR_VERSION}.x"
218252
else
@@ -223,48 +257,45 @@ jobs:
223257
--header "Authorization: Token ${{ secrets.READTHEDOCS_TOKEN }}" \
224258
--data '{
225259
"active": true,
226-
"hidden": false
260+
"hidden": $HIDDEN
227261
}'
228262
229263
inform_discord:
230264
runs-on: ubuntu-latest
231-
needs: [lib_release,docs_release,pre_config]
265+
needs: [docs_release, lib_release, pre_config]
232266
environment: release
233267
steps:
234268
- name: "Notify Discord"
235269
run: |
236270
VERSION=${{ needs.pre_config.outputs.version }}
237271
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
238-
if [[ $VERSION == *rc* ]]; then
239-
DOCS_URL="<https://docs.pycord.dev/en/v${MAJOR_MINOR_VERSION}.x/changelog.html>"
240-
else
241-
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
242-
fi
272+
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
243273
GITHUB_COMPARE_URL="<https://github.com/Pycord-Development/pycord/compare/${{ needs.pre_config.outputs.previous_tag }}...v$VERSION>"
244274
GITHUB_RELEASE_URL="<https://github.com/Pycord-Development/pycord/releases/tag/v$VERSION>"
245275
PYPI_RELEASE_URL="<https://pypi.org/project/py-cord/$VERSION/>"
246276
if [[ $VERSION == *rc* ]]; then
247-
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} Release Candidate ($VERSION) is available!\n\n"
277+
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v$VERSION Release Candidate ($MAJOR_MINOR_VERSION) is available!\n\n"
278+
ANNOUNCEMENT="${ANNOUNCEMENT}@here\n\n"
248279
ANNOUNCEMENT="${ANNOUNCEMENT}This is a pre-release (release candidate) for testing and feedback.\n\n"
249280
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
250281
ANNOUNCEMENT="${ANNOUNCEMENT}Check out the [GitHub changelog]($GITHUB_COMPARE_URL), [GitHub release page]($GITHUB_RELEASE_URL), and [PyPI release page]($PYPI_RELEASE_URL).\n\n"
251282
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
252-
ANNOUNCEMENT="${ANNOUNCEMENT}Please try it out and let us know your feedback or any issues!\n@here"
283+
ANNOUNCEMENT="${ANNOUNCEMENT}Please try it out and let us know your feedback or any issues!"
253284
else
254-
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} is out!\n\n"
255-
ANNOUNCEMENT="${ANNOUNCEMENT}[@everyone]\n\n"
285+
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${VERSION} is out!\n\n"
286+
ANNOUNCEMENT="${ANNOUNCEMENT}@everyone\n\n"
256287
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
257288
ANNOUNCEMENT="${ANNOUNCEMENT}Feel free to take a look at the [GitHub changelog]($GITHUB_COMPARE_URL), [GitHub release page]($GITHUB_RELEASE_URL) and the [PyPI release page]($PYPI_RELEASE_URL).\n\n"
258-
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
289+
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`"
259290
fi
260291
curl -H "Content-Type: application/json" \
261292
-X POST \
262-
-d "{\"content\":\"$ANNOUNCEMENT\",\"allowed_mentions\":{\"parse\": [\"everyone\"]}}" \
293+
-d "{\"content\":\"$ANNOUNCEMENT\",\"allowed_mentions\":{\"parse\":[\"everyone\",\"roles\"]}}" \
263294
${{ secrets.DISCORD_WEBHOOK_URL }}
264295
265296
determine_milestone_id:
266297
runs-on: ubuntu-latest
267-
needs: [lib_release,pre_config]
298+
needs: [lib_release, pre_config]
268299
if: ${{ !contains(needs.pre_config.outputs.version, '-') }}
269300
outputs:
270301
old_milestone_version: ${{ steps.extract_version.outputs.old_milestone_version }}
@@ -286,8 +317,10 @@ jobs:
286317
287318
close_milestone:
288319
runs-on: ubuntu-latest
289-
needs: [determine_milestone_id,pre_config]
290-
if: ${{ !contains(needs.pre_config.outputs.version, 'rc') && endsWith(needs.pre_config.outputs.version, '.0') }}
320+
needs: [determine_milestone_id, pre_config]
321+
if:
322+
${{ !contains(needs.pre_config.outputs.version, 'rc') &&
323+
endsWith(needs.pre_config.outputs.version, '.0') }}
291324
environment: release
292325
env:
293326
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -308,3 +341,22 @@ jobs:
308341
run: |
309342
gh extension install valeriobelli/gh-milestone
310343
gh milestone create "${{ needs.determine_milestone_id.outputs.new_milestone_version }}"
344+
345+
branch_protection_restore:
346+
runs-on: ubuntu-latest
347+
needs: [branch_protection_rename, lib_release, docs_release, inform_discord, determine_milestone_id, close_milestone]
348+
environment: release
349+
if: always()
350+
env:
351+
GH_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
352+
steps:
353+
- name: Restore master protection pattern
354+
if: ${{ needs.branch_protection_rename.outputs.master_rule_id != '' }}
355+
run: |
356+
gh api repos/${{ github.repository }}/branch-protection-rules/${{ needs.branch_protection_rename.outputs.master_rule_id }} \
357+
-X PATCH -F pattern="${{ needs.branch_protection_rename.outputs.master_pattern }}"
358+
- name: Restore v*.* protection pattern
359+
if: ${{ needs.branch_protection_rename.outputs.v_rule_id != '' }}
360+
run: |
361+
gh api repos/${{ github.repository }}/branch-protection-rules/${{ needs.branch_protection_rename.outputs.v_rule_id }} \
362+
-X PATCH -F pattern="${{ needs.branch_protection_rename.outputs.v_pattern }}"

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ These changes are available on the `master` branch, but have not yet been releas
1616

1717
### Fixed
1818

19+
- Manage silence for new SSRC with existing user_id.
20+
([#2808](https://github.com/Pycord-Development/pycord/pull/2808))
21+
- Fixed Async I/O errors that could be raised when using `Client.run`.
22+
([#2645](https://github.com/Pycord-Development/pycord/pull/2645))
23+
1924
### Removed
2025

2126
## [2.7.0rc1] - 2025-08-30
@@ -126,8 +131,6 @@ These changes are available on the `master` branch, but have not yet been releas
126131
([#2624](https://github.com/Pycord-Development/pycord/pull/2624))
127132
- Fixed editing `ForumChannel` flags not working.
128133
([#2641](https://github.com/Pycord-Development/pycord/pull/2641))
129-
- Fixed Async I/O errors that could be raised when using `Client.run`.
130-
([#2645](https://github.com/Pycord-Development/pycord/pull/2645))
131134
- Fixed `AttributeError` when accessing `Member.guild_permissions` for user installed
132135
apps. ([#2650](https://github.com/Pycord-Development/pycord/pull/2650))
133136
- Fixed type annotations of cached properties.

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for D
1717
.. image:: https://img.shields.io/github/v/release/Pycord-Development/pycord?include_prereleases&label=Latest%20Release&logo=github&sort=semver&style=for-the-badge&logoColor=white
1818
:target: https://github.com/Pycord-Development/pycord/releases
1919
:alt: Latest release
20-
2120
.. image:: https://img.shields.io/discord/881207955029110855?label=discord&style=for-the-badge&logo=discord&color=5865F2&logoColor=white
2221
:target: https://pycord.dev/discord
2322
:alt: Discord server invite
24-
23+
.. image:: https://img.shields.io/github/sponsors/Pycord-Development?style=for-the-badge
24+
:target: https://github.com/sponsors/Pycord-Development
25+
:alt: GitHub Sponsors
2526
.. image:: https://badges.crowdin.net/badge/dark/crowdin-on-light.png
2627
:target: https://translations.pycord.dev/documentation/?utm_source=badge&utm_medium=referral&utm_campaign=badge-add-on
2728
:alt: Crowdin | Agile localization for tech companies

discord/commands/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ def _parse_options(self, params, *, check_params: bool = True) -> list[Option]:
806806
if option == inspect.Parameter.empty:
807807
option = str
808808

809+
option = Option._strip_none_type(option)
809810
if self._is_typing_literal(option):
810811
literal_values = get_args(option)
811812
if not all(isinstance(v, (str, int, float)) for v in literal_values):

discord/commands/options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ def _strip_none_type(input_type):
386386
raise TypeError("Option type cannot be only NoneType")
387387
if len(filtered) == 1:
388388
return filtered[0]
389-
if all(getattr(t, "__origin__", None) is Literal for t in filtered):
390-
return Union[filtered]
391-
return Union[filtered]
389+
390+
return filtered
391+
392392
return input_type
393393

394394
def to_dict(self) -> dict:

0 commit comments

Comments
 (0)