Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/docs-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: "requirements/docs.txt"
check-latest: true
- name: Install dependencies
run: |
python -m pip install -U pip
pip install ".[docs]"
- name: "Install uv"
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Sync dependencies
run: uv sync --no-python-downloads --group dev --group docs
- name: "Check Links"
env:
SPHINXBUILD: ${{ github.workspace }}/.venv/bin/sphinx-build
if: ${{ github.event_name == 'schedule' || inputs.with_linkcheck }}
run: |
cd docs
make linkcheck
- name: "Compile to html"
env:
SPHINXBUILD: ${{ github.workspace }}/.venv/bin/sphinx-build
run: |
cd docs
make -e SPHINXOPTS="-D language='en'" html
111 changes: 24 additions & 87 deletions .github/workflows/lib-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: "Install uv"
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Sync dependencies
run: uv sync --no-python-downloads --group dev
- name: "Run codespell"
run:
codespell --ignore-words-list="groupt,nd,ot,ro,falsy,BU" \
uv run codespell --ignore-words-list="groupt,nd,ot,ro,falsy,BU" \
--exclude-file=".github/workflows/codespell.yml"
bandit:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: removed because included in the ruff linter

if: ${{ github.event_name != 'schedule' }}
ruff:
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
Expand All @@ -57,38 +56,16 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: "Run bandit"
run: bandit --recursive --skip B101,B104,B105,B110,B307,B311,B404,B603,B607 .
pylint:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Setup Python"
uses: actions/setup-python@v5
- name: "Install uv"
uses: astral-sh/setup-uv@v6
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: "Setup cache"
id: cache-pylint
uses: actions/cache@v4
with:
path: .pylint.d
key: pylint
- name: "Run pylint"
run: pylint discord/ --exit-zero
enable-cache: true
- name: Sync dependencies
run: uv sync --no-python-downloads --group dev
- name: "Run ruff linter check"
run: uv run ruff check discord/
- name: "Run ruff formatter check"
run: uv run ruff format --check discord/
mypy:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
Expand All @@ -99,12 +76,12 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: "Install uv"
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Sync dependencies
run: uv sync --no-python-downloads --group dev
- name: "Setup cache"
id: cache-mypy
uses: actions/cache@v4
Expand All @@ -115,44 +92,4 @@ jobs:
id: cache-dir-mypy
run: mkdir -p -v .mypy_cache
- name: "Run mypy"
run: mypy --non-interactive discord/
pytest:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: despite being called pytest this didn't run any tests but rather just ran the linting checks which is now done by ruff

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
exclude:
- { python-version: "3.9", os: "macos-latest" }
include:
- { python-version: "3.9", os: "macos-13" }
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
check-latest: true
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r requirements/dev.txt
- name: "Setup cache"
id: cache-pytest
uses: actions/cache@v4
with:
path: .pytest_cache
key: ${{ matrix.os }}-${{ matrix.python-version }}-pytest
- name: "Lint with flake8"
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
run: uv run mypy --non-interactive discord/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ docs/_build
__pycache__
.vs/*
.vscode/*
test.py
node_modules/*

# changelog is autogenerated from CHANGELOG.md
Expand All @@ -192,3 +191,5 @@ docs/build/linkcheck
!docs/locales/*
/build/
/vscode/

/discord/_version.py
75 changes: 5 additions & 70 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,65 +10,12 @@ repos:
exclude: \.(po|pot|yml|yaml)$
- id: end-of-file-fixer
exclude: \.(po|pot|yml|yaml)$
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.9
hooks:
- id: autoflake
# args:
# - --in-place
# - --remove-all-unused-imports
# - --expand-star-imports
# - --remove-duplicate-keys
# - --remove-unused-variables
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
exclude: \.(po|pot|yml|yaml)$
- repo: https://github.com/PyCQA/isort
rev: 6.0.1
hooks:
- id: isort
exclude: \.(po|pot|yml|yaml)$
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
args: [--safe, --quiet]
exclude: \.(po|pot|yml|yaml)$
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker
rev: v1.1.3
hooks:
- id: black-disable-checker
# - repo: https://github.com/PyCQA/flake8
# rev: 4.0.1
# hooks:
# - id: flake8
# additional_dependencies: [flake8-typing-imports==1.12.0]
# - repo: local
# hooks:
# - id: pylint
# name: pylint
# entry: pylint
# language: system
# types: [python]
# args: ["-rn", "-sn", "--rcfile=.pylintrc", "--fail-on=I"]
# # We define an additional manual step to allow running pylint with a spelling
# # checker in CI.
# - id: pylint
# alias: pylint-with-spelling
# name: pylint
# entry: pylint
# language: system
# types: [python]
# args: ["-rn", "-sn", "--rcfile=.pylintrc", "--fail-on=I", "--spelling-dict=en"]
# stages: [manual]
# - id: mypy
# name: mypy
# entry: mypy
# language: system
# types: [python]
# args: ["--non-interactive"]
- id: ruff
args: [ --fix ]
- id: ruff-format
# - repo: https://github.com/myint/rstcheck
# rev: "v5.0.0"
# hooks:
Expand All @@ -86,15 +33,3 @@ repos:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
exclude: \.(po|pot|yml|yaml)$
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: v0.7.3
hooks:
- id: pydocstringformatter
exclude: \.(po|pot|yml|yaml)$
args:
[
--style=numpydoc,
--no-numpydoc-name-type-spacing,
--no-final-period,
--no-capitalize-first-letter,
]
21 changes: 0 additions & 21 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# We need __version__ to be imported first
# isort: off
from ._version import *
from .__version import *

# isort: on

Expand Down
34 changes: 8 additions & 26 deletions discord/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,10 @@


def show_version() -> None:
entries = [
"- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(
sys.version_info
)
]
entries = ["- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(sys.version_info)]

version_info = discord.version_info
entries.append(
"- py-cord v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(version_info)
)
entries.append("- py-cord v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(version_info))
if version_info.releaselevel != "final":
version = importlib.metadata.version("py-cord")
if version:
Expand Down Expand Up @@ -299,9 +293,7 @@ def newcog(parser, args) -> None:


def add_newbot_args(subparser: argparse._SubParsersAction) -> None:
parser = subparser.add_parser(
"newbot", help="creates a command bot project quickly"
)
parser = subparser.add_parser("newbot", help="creates a command bot project quickly")
parser.set_defaults(func=newbot)

parser.add_argument("name", help="the bot project name")
Expand All @@ -311,12 +303,8 @@ def add_newbot_args(subparser: argparse._SubParsersAction) -> None:
nargs="?",
default=Path.cwd(),
)
parser.add_argument(
"--prefix", help="the bot prefix (default: $)", default="$", metavar="<prefix>"
)
parser.add_argument(
"--sharded", help="whether to use AutoShardedBot", action="store_true"
)
parser.add_argument("--prefix", help="the bot prefix (default: $)", default="$", metavar="<prefix>")
parser.add_argument("--sharded", help="whether to use AutoShardedBot", action="store_true")
parser.add_argument(
"--no-git",
help="do not create a .gitignore file",
Expand Down Expand Up @@ -347,18 +335,12 @@ def add_newcog_args(subparser: argparse._SubParsersAction) -> None:
help="whether to hide all commands in the cog",
action="store_true",
)
parser.add_argument(
"--full", help="add all special methods as well", action="store_true"
)
parser.add_argument("--full", help="add all special methods as well", action="store_true")


def parse_args() -> Tuple[argparse.ArgumentParser, argparse.Namespace]:
parser = argparse.ArgumentParser(
prog="discord", description="Tools for helping with Pycord"
)
parser.add_argument(
"-v", "--version", action="store_true", help="shows the library version"
)
parser = argparse.ArgumentParser(prog="discord", description="Tools for helping with Pycord")
parser.add_argument("-v", "--version", action="store_true", help="shows the library version")
parser.set_defaults(func=core)

subparser = parser.add_subparsers(dest="subcommand", title="subcommands")
Expand Down
Loading