Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv authored Feb 5, 2025
2 parents 041d676 + ce88413 commit df62030
Show file tree
Hide file tree
Showing 82 changed files with 560 additions and 753 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# force LF for pyproject to make hashFiles in CI consistent (windows <3)
# (see https://github.com/actions/runner/issues/498)
pyproject.toml text eol=lf
42 changes: 42 additions & 0 deletions .github/actions/cache-pdm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SPDX-License-Identifier: MIT

name: Configure PDM cache
description: .
inputs:
env-already-initialized:
description: Whether Python/PDM is already configured
required: false
default: 'true'

runs:
using: composite
steps:
- name: Get metadata for cache
id: get-cache-meta
shell: bash
run: |
echo "date=$(date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
- name: Setup/Restore cache
id: cache
uses: actions/cache@v4
with:
path: |
pdm.lock
# cache lockfile for the current day, roughly
key: pdm-${{ steps.get-cache-meta.outputs.date }}-${{ hashFiles('pyproject.toml') }}
# pdm lockfiles should be platform-agnostic
enableCrossOsArchive: true

- if: ${{ steps.cache.outputs.cache-hit != 'true' && inputs.env-already-initialized != 'true' }}
name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: 3.8
version: "2.20.1"

- if: ${{ steps.cache.outputs.cache-hit != 'true' }}
name: Lock all dependencies
shell: bash
run: |
pdm lock -G:all # create pdm.lock
15 changes: 4 additions & 11 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ inputs:
python-version:
description: The python version to install
required: true
cache-dependency-path:
description: The path(s) to use for pip caching, defaults to setup + pdm
required: false
default: |
pyproject.toml
setup.py
outputs:
python-version:
description: The python version that was installed.
Expand All @@ -25,12 +19,8 @@ runs:
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ inputs.python-version }}
version: "2.4.6"
version: "2.20.1" # last version to support python 3.8
cache: false
cache-dependency-path: ${{ inputs.cache-dependency-path }}
enable-pep582: false # Disable PEP 582 package loading globally
env:
PDM_DEPS: 'importlib-metadata<8; python_version < "3.10"'

- name: Disable PDM version check
shell: bash
Expand All @@ -54,3 +44,6 @@ runs:
id: python-version
shell: bash
run: echo "python-version=$(python -c 'import sys; print(".".join(map(str,sys.version_info[:2])))')" >> $GITHUB_OUTPUT

- name: Configure cache
uses: ./.github/actions/cache-pdm
33 changes: 26 additions & 7 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,25 @@ defaults:
shell: bash

jobs:
lint:
lock-dependencies:
# The only purpose of this is to create a lockfile, which will be cached
# to be used with subsequent jobs.
# This provides somewhat of a middle ground and avoids having each job lock dependencies on its own,
# while still not needing to commit a lockfile to the repo, which is discouraged for libraries as per
# https://pdm-project.org/en/latest/usage/lockfile/
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Instead of setup-env, we call the cache-pdm action here directly.
# This avoids having to install PDM, only to find out the cache is already up to date sometimes.
- name: Configure cache
uses: ./.github/actions/cache-pdm
with:
env-already-initialized: false

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand All @@ -36,9 +52,10 @@ jobs:
uses: pre-commit/[email protected]

docs:
# unlike the other workflows, we are using version 20.04 here as
# readthedocs uses 20.04 for building our docs, and we want to be explicit
runs-on: ubuntu-20.04
# unlike the other workflows, we explicitly use the same version as
# readthedocs (see .readthedocs.yml) here for consistency
runs-on: ubuntu-24.04
needs: lock-dependencies
steps:
- uses: actions/checkout@v4

Expand All @@ -52,10 +69,10 @@ jobs:

pyright:
runs-on: ubuntu-latest
needs: lock-dependencies
strategy:
matrix:
# FIXME: using specific patch version for 3.12 due to pdm bug
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.7"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
experimental: [false]
fail-fast: false
continue-on-error: ${{ matrix.experimental }}
Expand Down Expand Up @@ -105,6 +122,7 @@ jobs:

misc:
runs-on: ubuntu-latest
needs: lock-dependencies
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -148,9 +166,10 @@ jobs:
pytest:
runs-on: ${{ matrix.os }}
needs: lock-dependencies
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.7"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
experimental: [false]
fail-fast: true
Expand Down
2 changes: 1 addition & 1 deletion .libcst.codemod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ generated_code_marker: '@generated_module'
# Command line and arguments for invoking a code formatter. Anything
# specified here must be capable of taking code via stdin and returning
# formatted code via stdout.
formatter: ['black', '-q' , '-']
formatter: ['ruff', 'format' , '-']
# List of regex patterns which LibCST will evaluate against filenames to
# determine if the module should be touched.
blacklist_patterns: []
Expand Down
11 changes: 3 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@ repos:
args: [--negate]
types: [text]
exclude_types: [json, pofile]
exclude: 'changelog/|py.typed|disnake/bin/COPYING|.github/PULL_REQUEST_TEMPLATE.md|.github/CODEOWNERS|LICENSE|MANIFEST.in'

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black
name: "run black in all files"
exclude: 'changelog/|py.typed|disnake/bin/COPYING|.github/PULL_REQUEST_TEMPLATE.md|.github/CODEOWNERS|LICENSE|MANIFEST.in|.gitattributes'

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.8.0
rev: v0.9.3
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --fixable=I]
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2
formats:
- htmlzip
build:
os: ubuntu-20.04
os: ubuntu-24.04
tools:
python: "3.8"
sphinx:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ Specific development aspects are further explained below.

### Initial setup

We use [`PDM`](https://pdm.fming.dev/) as our dependency manager. If it isn't already installed on your system, you can follow the installation steps [here](https://pdm.fming.dev/latest/#installation) to get started.
We use [`PDM`](https://pdm-project.org/) as our dependency manager. If it isn't already installed on your system, you can follow the installation steps [here](https://pdm-project.org/latest/#installation) to get started.

Once PDM is installed, use the following command to initialize a virtual environment, install the necessary development dependencies, and install the [`pre-commit`](#pre-commit) hooks.
```
$ pdm run setup_env
```

Other tools used in this project include [black](https://black.readthedocs.io/en/stable/) (formatter), [ruff](https://beta.ruff.rs/docs/) (linter), and [pyright](https://microsoft.github.io/pyright/#/) (type-checker). For the most part, these automatically run on every commit with no additional action required - see below for details.
Other tools used in this project include [ruff](https://docs.astral.sh/ruff) (formatter and linter), and [pyright](https://microsoft.github.io/pyright/#/) (type-checker). For the most part, these automatically run on every commit with no additional action required - see below for details.

All of the following checks also automatically run for every PR on GitHub, so don't worry if you're not sure whether you missed anything. A PR cannot be merged as long as there are any failing checks.

Expand Down
1 change: 1 addition & 0 deletions changelog/1272.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Decrease the default :attr:`Guild.filesize_limit` from 25MB to 10MB.
1 change: 1 addition & 0 deletions changelog/1275.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix missing/faulty :class:`Subscription`\-related gateway events.
1 change: 1 addition & 0 deletions changelog/1278.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update internal package management tooling to latest versions, speed up CI by caching dependency metadata.
33 changes: 11 additions & 22 deletions disnake/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ class GuildChannel(ABC):

def __init__(
self, *, state: ConnectionState, guild: Guild, data: Mapping[str, Any]
) -> None:
...
) -> None: ...

def __str__(self) -> str:
return self.name
Expand Down Expand Up @@ -843,8 +842,7 @@ async def set_permissions(
*,
overwrite: Optional[PermissionOverwrite] = ...,
reason: Optional[str] = ...,
) -> None:
...
) -> None: ...

@overload
@_overload_with_permissions
Expand Down Expand Up @@ -911,8 +909,7 @@ async def set_permissions(
view_channel: Optional[bool] = ...,
view_creator_monetization_analytics: Optional[bool] = ...,
view_guild_insights: Optional[bool] = ...,
) -> None:
...
) -> None: ...

async def set_permissions(
self,
Expand Down Expand Up @@ -1118,8 +1115,7 @@ async def move(
category: Optional[Snowflake] = ...,
sync_permissions: bool = ...,
reason: Optional[str] = ...,
) -> None:
...
) -> None: ...

@overload
async def move(
Expand All @@ -1130,8 +1126,7 @@ async def move(
category: Optional[Snowflake] = ...,
sync_permissions: bool = ...,
reason: Optional[str] = ...,
) -> None:
...
) -> None: ...

@overload
async def move(
Expand All @@ -1142,8 +1137,7 @@ async def move(
category: Optional[Snowflake] = ...,
sync_permissions: bool = ...,
reason: Optional[str] = ...,
) -> None:
...
) -> None: ...

@overload
async def move(
Expand All @@ -1154,8 +1148,7 @@ async def move(
category: Optional[Snowflake] = ...,
sync_permissions: bool = ...,
reason: Optional[str] = ...,
) -> None:
...
) -> None: ...

async def move(self, **kwargs: Any) -> None:
"""|coro|
Expand Down Expand Up @@ -1442,8 +1435,7 @@ async def send(
view: View = ...,
components: Components[MessageUIComponent] = ...,
poll: Poll = ...,
) -> Message:
...
) -> Message: ...

@overload
async def send(
Expand All @@ -1464,8 +1456,7 @@ async def send(
view: View = ...,
components: Components[MessageUIComponent] = ...,
poll: Poll = ...,
) -> Message:
...
) -> Message: ...

@overload
async def send(
Expand All @@ -1486,8 +1477,7 @@ async def send(
view: View = ...,
components: Components[MessageUIComponent] = ...,
poll: Poll = ...,
) -> Message:
...
) -> Message: ...

@overload
async def send(
Expand All @@ -1508,8 +1498,7 @@ async def send(
view: View = ...,
components: Components[MessageUIComponent] = ...,
poll: Poll = ...,
) -> Message:
...
) -> Message: ...

async def send(
self,
Expand Down
6 changes: 2 additions & 4 deletions disnake/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,13 +890,11 @@ def __repr__(self) -> str:
@overload
def create_activity(
data: Union[ActivityPayload, WidgetActivityPayload], *, state: Optional[ConnectionState] = None
) -> ActivityTypes:
...
) -> ActivityTypes: ...


@overload
def create_activity(data: None, *, state: Optional[ConnectionState] = None) -> None:
...
def create_activity(data: None, *, state: Optional[ConnectionState] = None) -> None: ...


def create_activity(
Expand Down
8 changes: 3 additions & 5 deletions disnake/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _transform(entry: AuditLogEntry, data: Optional[int]) -> Optional[FlagsT]:


def _list_transformer(
func: Callable[[AuditLogEntry, Any], T]
func: Callable[[AuditLogEntry, Any], T],
) -> Callable[[AuditLogEntry, Any], List[T]]:
def _transform(entry: AuditLogEntry, data: Any) -> List[T]:
if not data:
Expand Down Expand Up @@ -303,11 +303,9 @@ def __repr__(self) -> str:

if TYPE_CHECKING:

def __getattr__(self, item: str) -> Any:
...
def __getattr__(self, item: str) -> Any: ...

def __setattr__(self, key: str, value: Any) -> Any:
...
def __setattr__(self, key: str, value: Any) -> Any: ...


Transformer = Callable[["AuditLogEntry", Any], Any]
Expand Down
Loading

0 comments on commit df62030

Please sign in to comment.