From 7ace9bcbaa882edaed29fdcff7c70a3859849b5f Mon Sep 17 00:00:00 2001 From: arielle Date: Tue, 9 Sep 2025 13:21:31 -0400 Subject: [PATCH 1/6] feat: add pyproject-fmt config --- .pre-commit-config.yaml | 5 +++++ pyproject.toml | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb13e304fa..051c154c5c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,6 +19,11 @@ repos: - id: pretty-format-yaml args: [--autofix, --indent, '2', --offset, '2', '--preserve-quotes'] + - repo: https://github.com/tox-dev/pyproject-fmt + rev: "v2.6.0" + hooks: + - id: pyproject-fmt + - repo: local hooks: - id: no-symlinks diff --git a/pyproject.toml b/pyproject.toml index b18c2258c6..ae72df8050 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -276,6 +276,12 @@ extend-immutable-calls = [ [tool.ruff.lint.flake8-annotations] ignore-fully-untyped = true +[tool.pyproject-fmt] +column_width = 40 +indent = 4 +keep_full_version = true +max_supported_python = "3.13" + [tool.towncrier] template = "changelog/_template.rst.jinja" package = "disnake" From c74647fbab06bf2cd00efbf0bcfbec7870742b6c Mon Sep 17 00:00:00 2001 From: arielle Date: Tue, 9 Sep 2025 13:22:47 -0400 Subject: [PATCH 2/6] run pyproject-fmt --- pyproject.toml | 452 ++++++++++++++++++++++++------------------------- 1 file changed, 225 insertions(+), 227 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ae72df8050..bb8a947978 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,28 +1,30 @@ # SPDX-License-Identifier: MIT [build-system] -requires = ["setuptools>=61"] build-backend = "setuptools.build_meta" +requires = [ "setuptools>=61" ] [project] name = "disnake" description = "A Python wrapper for the Discord API" readme = "README.md" -authors = [ - { name = "Disnake Development" } +keywords = [ + "discord", + "discord api", + "disnake", ] -requires-python = ">=3.8" -keywords = ["disnake", "discord", "discord api"] license = { text = "MIT" } -dependencies = [ - "aiohttp>=3.7.0,<4.0", +authors = [ + { name = "Disnake Development" }, ] +requires-python = ">=3.8" classifiers = [ "Development Status :: 5 - Production/Stable", - "License :: OSI Approved :: MIT License", "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -35,158 +37,153 @@ classifiers = [ "Topic :: Utilities", "Typing :: Typed", ] -dynamic = ["version"] - -[project.urls] -Changelog = "https://docs.disnake.dev/page/whats_new.html" -Documentation = "https://docs.disnake.dev/" -Repository = "https://github.com/DisnakeDev/disnake" - -[project.optional-dependencies] -speed = [ - "orjson~=3.6", - # taken from aiohttp[speedups] - "aiodns>=1.1", - "Brotli", - 'cchardet; python_version < "3.10"', -] -voice = [ - "PyNaCl>=1.5.0,<1.6", - 'audioop-lts==0.2.1; python_version >= "3.13"' +dynamic = [ "version" ] +dependencies = [ + "aiohttp>=3.7.0,<4.0", ] -docs = [ +optional-dependencies.docs = [ "sphinx==7.0.1", - "sphinxcontrib-trio~=1.1.2", - "sphinx-hoverxref==1.3.0", "sphinx-autobuild~=2021.3", - "sphinxcontrib-towncrier==0.3.2a0", - "towncrier==23.6.0", + "sphinx-hoverxref==1.3.0", "sphinx-notfound-page==0.8.3", + "sphinxcontrib-towncrier==0.3.2a0", + "sphinxcontrib-trio~=1.1.2", "sphinxext-opengraph==0.9.1", + "towncrier==23.6.0", ] +optional-dependencies.speed = [ + # taken from aiohttp[speedups] + "aiodns>=1.1", + "brotli", + "cchardet; python_version<'3.10'", + "orjson~=3.6", +] +optional-dependencies.voice = [ + "audioop-lts==0.2.1; python_version>='3.13'", + "pynacl>=1.5.0,<1.6", +] +urls.Changelog = "https://docs.disnake.dev/page/whats_new.html" +urls.Documentation = "https://docs.disnake.dev/" +urls.Repository = "https://github.com/DisnakeDev/disnake" [dependency-groups] +test = [ + "coverage[toml]~=7.6.0", + "looptime~=0.2.0", + "pytest~=8.3.2", + "pytest-asyncio~=0.24.0", + "pytest-cov~=4.0.0", +] nox = [ "nox==2025.5.1", ] tools = [ - "pre-commit~=3.0", - "slotscheck~=0.16.4", "check-manifest==0.49", + "pre-commit~=3.0", "ruff==0.12.12", + "slotscheck~=0.16.4", ] changelog = [ "towncrier==23.6.0", ] codemod = [ + "autotyping==23.2.0", # run codemods on the respository (mostly automated typing) "libcst~=1.1.0", "ruff==0.12.12", - "autotyping==23.2.0", ] typing = [ # this is not pyright itself, but the python wrapper "pyright==1.1.336", - "typing-extensions~=4.12.0", # only used for type-checking, version does not matter "pytz", -] -test = [ - "pytest~=8.3.2", - "pytest-cov~=4.0.0", - "pytest-asyncio~=0.24.0", - "looptime~=0.2.0", - "coverage[toml]~=7.6.0", + "typing-extensions~=4.12.0", ] build = [ - "wheel~=0.40.0", "build~=0.10.0", "twine~=5.1.1", + "wheel~=0.40.0", ] -[tool.setuptools.packages.find] -where = ["."] -include = ["disnake*"] - -[tool.nox] -script-venv-backend = "uv|virtualenv" - [tool.pdm] # Ignore `requires-python` warnings when locking, the latest versions of some # dependencies already require >=3.9 # See also https://pdm-project.org/en/latest/usage/config/#ignore-package-warnings -ignore_package_warnings = ["*"] +ignore_package_warnings = [ "*" ] [tool.pdm.scripts] docs = { cmd = "nox -Rs docs --", help = "Build the documentation for development" } lint = { cmd = "nox -Rs lint --", help = "Check all files for linting errors" } pyright = { cmd = "nox -Rs pyright --", help = "Run pyright" } setup_env = { cmd = "{pdm} install -G:all", help = "Set up the local environment and all dependencies" } -post_setup_env = { composite = ["python -m ensurepip --default-pip", "pre-commit install --install-hooks"] } +post_setup_env = { composite = [ + "python -m ensurepip --default-pip", + "pre-commit install --install-hooks", +] } test = { cmd = "nox -Rs test --", help = "Run pytest" } +[tool.setuptools.packages.find] +where = [ "." ] +include = [ "disnake*" ] + [tool.ruff] -line-length = 100 target-version = "py38" -[tool.ruff.lint] -select = [ - # commented out codes are intended to be enabled in future prs - "F", # pyflakes - "E", "W", # pycodestyle +line-length = 100 +lint.select = [ + "ANN2", # flake8-annotations + "B", # flake8-bugbear + "C4", # flake8-comprehensions # "D", # pydocstyle "D2", # pydocstyle, docstring formatting "D4", # pydocstyle, docstring structure/content - "ANN2", # flake8-annotations - "S", # flake8-bandit - "B", # flake8-bugbear - "C4", # flake8-comprehensions "DTZ", # flake8-datetimez + "E", + # commented out codes are intended to be enabled in future prs + "F", # pyflakes # "EM", # flake8-errmsg - "G", # flake8-logging-format + "G", # flake8-logging-format + "I", # isort + "PGH", # pygrep-hooks + "PLC", # pylint convention + "PLE", # pylint error + # "PLR", # pylint refactor + "PLW", # pylint warnings + "PT", # flake8-pytest-style + "Q", # flake8-quotes + "RSE", # flake8-raise + "RUF", # ruff specific exceptions + "S", # flake8-bandit + "T20", # flake8-print + "TC", # flake8-type-checking # "RET", # flake8-return # "SIM", # flake8-simplify "TID251", # flake8-tidy-imports, replaces S404 - "TC", # flake8-type-checking - "RUF", # ruff specific exceptions - "PT", # flake8-pytest-style - "Q", # flake8-quotes - "RSE", # flake8-raise - "T20", # flake8-print - "PGH", # pygrep-hooks - "PLC", # pylint convention - "PLE", # pylint error - # "PLR", # pylint refactor - "PLW", # pylint warnings - "TRY002", "TRY004", "TRY201", # tryceratops - "I", # isort + "TRY002", + "TRY004", + "TRY201", # tryceratops + "W", # pycodestyle ] -ignore = [ - # star imports - "F403", - +lint.ignore = [ + "B026", # backwards star-arg unpacking + "B904", # within an except clause raise from error or from none # pydocstyle "D203", # incompat with D211 + # temporary disables, to fix later + "D205", # blank line required between summary and description "D213", # multiline docstring should start on second line, incompatiable with D212 "D400", # first line ends in period, does not work with `|coro|` etc. + "D401", # first line of docstring should be in imperative mood "D415", # same thing but punctuation in general "D416", # section name should end with a colon, incompatible with D406 - # unknown if this is actually an issue - "RUF006", # might not be an issue/very extreme cases + "D417", # missing argument description in docstring + "E501", # line too long + "E731", # assigning lambdas to variables + "E741", # ambiguous variable names - # we keep __all__ and __slots__ (roughly) sorted by source, not alphabetically - "RUF022", - "RUF023", - - # calling subprocess with dynamic arguments is generally fine, the only way to avoid this is ignoring it - "S603", - - # partial executable paths (i.e. "git" instead of "/usr/bin/git") are fine - "S607", - - # ignore try-except-pass. Bare excepts are caught with E722 - "S110", + # star imports + "F403", # provide specific codes on type: ignore "PGH003", @@ -197,6 +194,14 @@ ignore = [ # import aliases are fixed by ruff "PLC0414", + # ignore non-to-level imports + "PLC0415", + + "PLE0237", # pyright seems to catch this already + + # object does not implement hashing + "PLW1641", + # outer loop variables are overwritten by inner assignment target, these are mostly intentional "PLW2901", @@ -204,12 +209,24 @@ ignore = [ # pytest.warns() without a match variable is too broad "PT030", - # object does not implement hashing - "PLW1641", + # unknown if this is actually an issue + "RUF006", # might not be an issue/very extreme cases - # ignore non-to-level imports - "PLC0415", + # we keep __all__ and __slots__ (roughly) sorted by source, not alphabetically + "RUF022", + "RUF023", + # ignore try-except-pass. Bare excepts are caught with E722 + "S110", + + "S311", # insecure RNG usage, we don't use these for security-related things + # calling subprocess with dynamic arguments is generally fine, the only way to avoid this is ignoring it + "S603", + + # partial executable paths (i.e. "git" instead of "/usr/bin/git") are fine + "S607", + + "T201", # print statements # ignore imports that could be moved into type-checking blocks # (no real advantage other than possibly avoiding cycles, # but can be dangerous in places where we need to parse signatures) @@ -217,64 +234,65 @@ ignore = [ "TC002", "TC003", - "S311", # insecure RNG usage, we don't use these for security-related things - "PLE0237", # pyright seems to catch this already - - "E741", # ambiguous variable names - - # temporary disables, to fix later - "D205", # blank line required between summary and description - "D401", # first line of docstring should be in imperative mood - "D417", # missing argument description in docstring - "B904", # within an except clause raise from error or from none - "B026", # backwards star-arg unpacking - "E501", # line too long - "E731", # assigning lambdas to variables - "T201", # print statements ] - -[tool.ruff.lint.per-file-ignores] -"disnake/__main__.py" = ["T201"] # print statements are okay in our simple cli -"disnake/i18n.py" = [ +lint.per-file-ignores."disnake/**.py" = [ + "PT", +] # this is not a module of pytest tests +lint.per-file-ignores."disnake/__main__.py" = [ + "T201", +] # print statements are okay in our simple cli +lint.per-file-ignores."disnake/i18n.py" = [ "B027", # lib bug. Excluded here because ruff does not have a --disable-noqa flag yet ] -"disnake/ui/select/*.py" = [ +lint.per-file-ignores."disnake/ui/select/*.py" = [ "F401", # unused imports. Excluded because there is a bug with ruff. ] -"disnake/**.py" = ["PT"] # this is not a module of pytest tests -"tests/*.py" = ["S101"] # use of assert is okay in test files -"scripts/*.py" = ["S101"] # use of assert is okay in scripts # we are not using noqa in the example files themselves -"examples/*.py" = [ +lint.per-file-ignores."examples/*.py" = [ + "ANN", # missing type annotations in examples is fine "B008", # do not perform function calls in argument defaults, this is how most commands work "PT", # this is not a module of pytest tests "S311", # pseudo-random generators aren't suitable for cryptographic purposes "T201", # print found, printing is okay in examples - "ANN", # missing type annotations in examples is fine ] -"examples/basic_voice.py" = ["S104"] # possible binding to all interfaces - -[tool.ruff.lint.isort] -combine-as-imports = true - -[tool.ruff.lint.pydocstyle] -convention = "numpy" - -[tool.ruff.lint.flake8-pytest-style] -fixture-parentheses = false -mark-parentheses = false - -[tool.ruff.lint.flake8-tidy-imports.banned-api] -"subprocess".msg = "Consider possible security implications associated with the subprocess module." # replaces S404 - -[tool.ruff.lint.flake8-bugbear] -extend-immutable-calls = [ +lint.per-file-ignores."examples/basic_voice.py" = [ + "S104", +] # possible binding to all interfaces +lint.per-file-ignores."scripts/*.py" = [ + "S101", +] # use of assert is okay in scripts +lint.per-file-ignores."tests/*.py" = [ + "S101", +] # use of assert is okay in test files +lint.flake8-annotations.ignore-fully-untyped = true +lint.flake8-bugbear.extend-immutable-calls = [ # this is immutable, except for storing locks, which are fine to share across contexts "disnake.webhook.async_.AsyncWebhookAdapter", ] +lint.flake8-pytest-style.fixture-parentheses = false +lint.flake8-pytest-style.mark-parentheses = false +lint.flake8-tidy-imports.banned-api."subprocess".msg = "Consider possible security implications associated with the subprocess module." # replaces S404 +lint.isort.combine-as-imports = true +lint.pydocstyle.convention = "numpy" -[tool.ruff.lint.flake8-annotations] -ignore-fully-untyped = true +[tool.check-manifest] +ignore = [ + # CI + ".pre-commit-config.yaml", + ".readthedocs.yml", + ".libcst.codemod.yaml", + "noxfile.py", + # docs + "CONTRIBUTING.md", + "RELEASE.md", + "assets/**", + "changelog/**", + "docs/**", + "examples/**", + # tests + "tests/**", + "scripts/**", +] [tool.pyproject-fmt] column_width = 40 @@ -282,6 +300,37 @@ indent = 4 keep_full_version = true max_supported_python = "3.13" +[tool.pytest.ini_options] +minversion = "8.2" +pythonpath = "." # legacy configuration, new pytest versions don't add the rootdir to path +testpaths = "tests" +addopts = "--strict-markers -Werror -s" +xfail_strict = true +asyncio_mode = "strict" + +[tool.coverage.run] +branch = true +include = [ + "disnake/*", + "tests/*", +] +omit = [ + "disnake/ext/mypy_plugin/*", + "disnake/types/*", + "disnake/__main__.py", +] + +[tool.coverage.report] +precision = 1 +exclude_lines = [ + "# pragma: no cov(er(age)?)?$", + "^\\s*def __repr__", + "^\\s*@overload", + "^\\s*if TYPE_CHECKING", + "^\\s*raise NotImplementedError$", + "^\\s*\\.\\.\\.$", +] + [tool.towncrier] template = "changelog/_template.rst.jinja" package = "disnake" @@ -291,47 +340,35 @@ title_format = false underlines = "-~" issue_format = ":issue:`{issue}`" - [[tool.towncrier.type]] - directory = "breaking" - name = "Breaking Changes" - showcontent = true - - [[tool.towncrier.type]] - directory = "deprecate" - name = "Deprecations" - showcontent = true - - [[tool.towncrier.type]] - directory = "feature" - name = "New Features" - showcontent = true - - [[tool.towncrier.type]] - directory = "bugfix" - name = "Bug Fixes" - showcontent = true +[[tool.towncrier.type]] +directory = "breaking" +name = "Breaking Changes" +showcontent = true - [[tool.towncrier.type]] - directory = "doc" - name = "Documentation" - showcontent = true +[[tool.towncrier.type]] +directory = "deprecate" +name = "Deprecations" +showcontent = true - [[tool.towncrier.type]] - directory = "misc" - name = "Miscellaneous" - showcontent = true +[[tool.towncrier.type]] +directory = "feature" +name = "New Features" +showcontent = true +[[tool.towncrier.type]] +directory = "bugfix" +name = "Bug Fixes" +showcontent = true -[tool.slotscheck] -strict-imports = true -require-superclass = true -require-subclass = false -exclude-modules = ''' -( - ^disnake\.types\. -) -''' +[[tool.towncrier.type]] +directory = "doc" +name = "Documentation" +showcontent = true +[[tool.towncrier.type]] +directory = "misc" +name = "Miscellaneous" +showcontent = true [tool.pyright] typeCheckingMode = "strict" @@ -371,54 +408,15 @@ reportMissingParameterType = false reportUnknownVariableType = false reportMissingTypeArgument = false +[tool.nox] +script-venv-backend = "uv|virtualenv" -[tool.pytest.ini_options] -minversion = "8.2" -pythonpath = "." # legacy configuration, new pytest versions don't add the rootdir to path -testpaths = "tests" -addopts = "--strict-markers -Werror -s" -xfail_strict = true -asyncio_mode = "strict" - -[tool.coverage.run] -branch = true -include = [ - "disnake/*", - "tests/*", -] -omit = [ - "disnake/ext/mypy_plugin/*", - "disnake/types/*", - "disnake/__main__.py", -] - -[tool.coverage.report] -precision = 1 -exclude_lines = [ - "# pragma: no cov(er(age)?)?$", - "^\\s*def __repr__", - "^\\s*@overload", - "^\\s*if TYPE_CHECKING", - "^\\s*raise NotImplementedError$", - "^\\s*\\.\\.\\.$", -] - - -[tool.check-manifest] -ignore = [ - # CI - ".pre-commit-config.yaml", - ".readthedocs.yml", - ".libcst.codemod.yaml", - "noxfile.py", - # docs - "CONTRIBUTING.md", - "RELEASE.md", - "assets/**", - "changelog/**", - "docs/**", - "examples/**", - # tests - "tests/**", - "scripts/**", -] +[tool.slotscheck] +strict-imports = true +require-superclass = true +require-subclass = false +exclude-modules = ''' +( + ^disnake\.types\. +) +''' From 7f275b995644122ca063f56fbf7de772baeeb068 Mon Sep 17 00:00:00 2001 From: arielle Date: Tue, 9 Sep 2025 13:43:01 -0400 Subject: [PATCH 3/6] fix: remove ruff target_version as it defaults to project.requires-python --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bb8a947978..279c0b00d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,8 +127,6 @@ where = [ "." ] include = [ "disnake*" ] [tool.ruff] -target-version = "py38" - line-length = 100 lint.select = [ "ANN2", # flake8-annotations From ab1a0c108c3791ce499d9e3901fb08581087aeb5 Mon Sep 17 00:00:00 2001 From: arielle Date: Tue, 9 Sep 2025 16:28:29 -0400 Subject: [PATCH 4/6] fix comments --- pyproject.toml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 279c0b00d0..a615199963 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,15 +88,13 @@ changelog = [ ] codemod = [ "autotyping==23.2.0", - # run codemods on the respository (mostly automated typing) "libcst~=1.1.0", "ruff==0.12.12", ] typing = [ # this is not pyright itself, but the python wrapper "pyright==1.1.336", - # only used for type-checking, version does not matter - "pytz", + "pytz", # only used for type-checking, version does not matter "typing-extensions~=4.12.0", ] build = [ @@ -128,6 +126,7 @@ include = [ "disnake*" ] [tool.ruff] line-length = 100 +# commented out codes are intended to be enabled in future prs lint.select = [ "ANN2", # flake8-annotations "B", # flake8-bugbear @@ -136,10 +135,9 @@ lint.select = [ "D2", # pydocstyle, docstring formatting "D4", # pydocstyle, docstring structure/content "DTZ", # flake8-datetimez - "E", - # commented out codes are intended to be enabled in future prs - "F", # pyflakes + "E", # pyflakes # "EM", # flake8-errmsg + "F", # pyflakes "G", # flake8-logging-format "I", # isort "PGH", # pygrep-hooks @@ -149,13 +147,13 @@ lint.select = [ "PLW", # pylint warnings "PT", # flake8-pytest-style "Q", # flake8-quotes + # "RET", # flake8-return "RSE", # flake8-raise "RUF", # ruff specific exceptions "S", # flake8-bandit - "T20", # flake8-print - "TC", # flake8-type-checking - # "RET", # flake8-return # "SIM", # flake8-simplify + "T20", # flake8-print + "TC", # flake8-type-checking "TID251", # flake8-tidy-imports, replaces S404 "TRY002", "TRY004", @@ -165,17 +163,16 @@ lint.select = [ lint.ignore = [ "B026", # backwards star-arg unpacking "B904", # within an except clause raise from error or from none - # pydocstyle + ## pydocstyle "D203", # incompat with D211 - # temporary disables, to fix later "D205", # blank line required between summary and description "D213", # multiline docstring should start on second line, incompatiable with D212 "D400", # first line ends in period, does not work with `|coro|` etc. "D401", # first line of docstring should be in imperative mood "D415", # same thing but punctuation in general "D416", # section name should end with a colon, incompatible with D406 - "D417", # missing argument description in docstring + "E501", # line too long "E731", # assigning lambdas to variables "E741", # ambiguous variable names @@ -195,7 +192,8 @@ lint.ignore = [ # ignore non-to-level imports "PLC0415", - "PLE0237", # pyright seems to catch this already + # pyright seems to catch this already + "PLE0237", # object does not implement hashing "PLW1641", @@ -224,7 +222,9 @@ lint.ignore = [ # partial executable paths (i.e. "git" instead of "/usr/bin/git") are fine "S607", - "T201", # print statements + # temporary disabled, to fix later + "T201", + # ignore imports that could be moved into type-checking blocks # (no real advantage other than possibly avoiding cycles, # but can be dangerous in places where we need to parse signatures) From 4d7527b6d76c5c7be4935aa7c2e669a5effd4e3f Mon Sep 17 00:00:00 2001 From: arielle Date: Tue, 9 Sep 2025 16:30:11 -0400 Subject: [PATCH 5/6] fix: remove commented out ruff config option --- pyproject.toml | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a615199963..93a827484b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,30 +128,25 @@ include = [ "disnake*" ] line-length = 100 # commented out codes are intended to be enabled in future prs lint.select = [ - "ANN2", # flake8-annotations - "B", # flake8-bugbear - "C4", # flake8-comprehensions - # "D", # pydocstyle - "D2", # pydocstyle, docstring formatting - "D4", # pydocstyle, docstring structure/content - "DTZ", # flake8-datetimez - "E", # pyflakes - # "EM", # flake8-errmsg - "F", # pyflakes - "G", # flake8-logging-format - "I", # isort - "PGH", # pygrep-hooks - "PLC", # pylint convention - "PLE", # pylint error - # "PLR", # pylint refactor - "PLW", # pylint warnings - "PT", # flake8-pytest-style - "Q", # flake8-quotes - # "RET", # flake8-return - "RSE", # flake8-raise - "RUF", # ruff specific exceptions - "S", # flake8-bandit - # "SIM", # flake8-simplify + "ANN2", # flake8-annotations + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "D2", # pydocstyle, docstring formatting + "D4", # pydocstyle, docstring structure/content + "DTZ", # flake8-datetimez + "E", # pyflakes + "F", # pyflakes + "G", # flake8-logging-format + "I", # isort + "PGH", # pygrep-hooks + "PLC", # pylint convention + "PLE", # pylint error + "PLW", # pylint warnings + "PT", # flake8-pytest-style + "Q", # flake8-quotes + "RSE", # flake8-raise + "RUF", # ruff specific exceptions + "S", # flake8-bandit "T20", # flake8-print "TC", # flake8-type-checking "TID251", # flake8-tidy-imports, replaces S404 From c2f3433b05f2265ef2491d0a4469305a973bfc41 Mon Sep 17 00:00:00 2001 From: onerandomusername Date: Wed, 10 Sep 2025 17:43:32 -0400 Subject: [PATCH 6/6] fix: sort a little more --- pyproject.toml | 92 +++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f21180b2eb..108f2de90f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -228,6 +228,7 @@ lint.ignore = [ "TC003", ] + lint.per-file-ignores."disnake/**.py" = [ "PT", ] # this is not a module of pytest tests @@ -249,23 +250,29 @@ lint.per-file-ignores."examples/*.py" = [ "T201", # print found, printing is okay in examples ] lint.per-file-ignores."examples/basic_voice.py" = [ - "S104", -] # possible binding to all interfaces + "S104", # possible binding to all interfaces +] lint.per-file-ignores."scripts/*.py" = [ - "S101", -] # use of assert is okay in scripts + "S101", # use of assert is okay in scripts +] lint.per-file-ignores."tests/*.py" = [ - "S101", -] # use of assert is okay in test files + "S101", # use of assert is okay in test files +] + lint.flake8-annotations.ignore-fully-untyped = true + lint.flake8-bugbear.extend-immutable-calls = [ # this is immutable, except for storing locks, which are fine to share across contexts "disnake.webhook.async_.AsyncWebhookAdapter", ] + lint.flake8-pytest-style.fixture-parentheses = false lint.flake8-pytest-style.mark-parentheses = false + lint.flake8-tidy-imports.banned-api."subprocess".msg = "Consider possible security implications associated with the subprocess module." # replaces S404 + lint.isort.combine-as-imports = true + lint.pydocstyle.convention = "numpy" [tool.codespell] @@ -275,9 +282,9 @@ ignore-words-list = [ 'GroupT', "OT" ] [tool.check-manifest] ignore = [ # CI + ".libcst.codemod.yaml", ".pre-commit-config.yaml", ".readthedocs.yml", - ".libcst.codemod.yaml", "noxfile.py", # docs "CONTRIBUTING.md", @@ -287,8 +294,8 @@ ignore = [ "docs/**", "examples/**", # tests - "tests/**", "scripts/**", + "tests/**", ] [tool.pyproject-fmt] @@ -299,11 +306,14 @@ max_supported_python = "3.13" [tool.pytest.ini_options] minversion = "8.2" -pythonpath = "." # legacy configuration, new pytest versions don't add the rootdir to path +pythonpath = "." # legacy configuration, new pytest versions don't add the rootdir to path + testpaths = "tests" addopts = "--strict-markers -Werror -s" xfail_strict = true + asyncio_mode = "strict" +asyncio_default_fixture_loop_scope = "function" [tool.coverage.run] branch = true @@ -312,9 +322,9 @@ include = [ "tests/*", ] omit = [ - "disnake/ext/mypy_plugin/*", - "disnake/types/*", "disnake/__main__.py", + "disnake/types/*", + "disnake/ext/mypy_plugin/*", ] [tool.coverage.report] @@ -337,35 +347,14 @@ title_format = false underlines = "-~" issue_format = ":issue:`{issue}`" -[[tool.towncrier.type]] -directory = "breaking" -name = "Breaking Changes" -showcontent = true - -[[tool.towncrier.type]] -directory = "deprecate" -name = "Deprecations" -showcontent = true - -[[tool.towncrier.type]] -directory = "feature" -name = "New Features" -showcontent = true - -[[tool.towncrier.type]] -directory = "bugfix" -name = "Bug Fixes" -showcontent = true - -[[tool.towncrier.type]] -directory = "doc" -name = "Documentation" -showcontent = true - -[[tool.towncrier.type]] -directory = "misc" -name = "Miscellaneous" -showcontent = true +type = [ + { directory = "breaking", name = "Breaking Changes", showcontent = true }, + { directory = "bugfix", name = "Bug Fixes", showcontent = true }, + { directory = "deprecate", name = "Deprecations", showcontent = true }, + { directory = "doc", name = "Documentation", showcontent = true }, + { directory = "feature", name = "New Features", showcontent = true }, + { directory = "misc", name = "Miscellaneous", showcontent = true }, +] [tool.pyright] typeCheckingMode = "strict" @@ -385,28 +374,25 @@ ignore = [ reportUnnecessaryTypeIgnoreComment = true # it's unlikely that these will ever be enabled -reportOverlappingOverload = false -reportPrivateUsage = false -reportUnnecessaryIsInstance = false -reportFunctionMemberAccess = false -reportMissingTypeStubs = false -reportUnusedFunction = false -reportUnusedClass = false reportConstantRedefinition = false +reportFunctionMemberAccess = false reportImportCycles = false reportIncompatibleMethodOverride = false reportIncompatibleVariableOverride = false +reportMissingTypeStubs = false +reportOverlappingOverload = false +reportPrivateUsage = false +reportUnnecessaryIsInstance = false +reportUnusedClass = false +reportUnusedFunction = false # these are largely due to missing type hints, and make up most of the error count +reportMissingParameterType = false +reportMissingTypeArgument = false +reportUnknownArgumentType = false reportUnknownMemberType = false reportUnknownParameterType = false -reportUnknownArgumentType = false -reportMissingParameterType = false reportUnknownVariableType = false -reportMissingTypeArgument = false - -[tool.nox] -script-venv-backend = "uv|virtualenv" [tool.slotscheck] strict-imports = true