From d74c52a461af6f7a0710583cd171e99a674bbae4 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Tue, 4 Oct 2022 09:38:47 -0500 Subject: [PATCH 01/19] Migrate isort to pyproject.toml --- .isort.cfg | 2 -- pyproject.toml | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 .isort.cfg diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index f238bf7ea1..0000000000 --- a/.isort.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[settings] -profile = black diff --git a/pyproject.toml b/pyproject.toml index 28256f5e78..e5706bc7eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,5 @@ [tool.black] target-version = ['py38', 'py39', 'py310', 'py311'] + +[tool.isort] +profile = "black" From 7efab26d12ea0b53089fde13ca9aa725413f31cd Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Tue, 4 Oct 2022 09:40:12 -0500 Subject: [PATCH 02/19] Migrate mypy to pyproject.toml --- mypy.ini | 8 -------- pyproject.toml | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 mypy.ini diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index c5189579f6..0000000000 --- a/mypy.ini +++ /dev/null @@ -1,8 +0,0 @@ -[mypy] -namespace_packages = True -install_types = True -strict = True -show_error_codes = True -;allow_untyped_decorators = True -;allow_untyped_calls = True -ignore_errors = True diff --git a/pyproject.toml b/pyproject.toml index e5706bc7eb..6612119fc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,3 +3,12 @@ target-version = ['py38', 'py39', 'py310', 'py311'] [tool.isort] profile = "black" + +[tool.mypy] +namespace_packages = true +install_types = true +strict = true +show_error_codes = true +#allow_untyped_decorators = true +#allow_untyped_calls = true +ignore_errors = true From 427e2a20f60541d175e6ef61be56ee357386dee4 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Tue, 4 Oct 2022 10:02:58 -0500 Subject: [PATCH 03/19] Migrate pylint to pyproject.toml --- .pylintrc | 15 --------------- pyproject.toml | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) delete mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index ccb1249f6b..0000000000 --- a/.pylintrc +++ /dev/null @@ -1,15 +0,0 @@ -[MASTER] -extension-pkg-whitelist=pydantic,ujson -py-version=3.8 - -[MESSAGES CONTROL] - -enable=bad-indentation,line-too-long -disable=protected-access,fixme - - -[FORMAT] - -indent-string=' ' - -max-line-length=120 diff --git a/pyproject.toml b/pyproject.toml index 6612119fc2..6e13133fa3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,3 +12,24 @@ show_error_codes = true #allow_untyped_decorators = true #allow_untyped_calls = true ignore_errors = true + +[tool.pylint.main] +extension-pkg-whitelist = [ + "pydantic", + "ujson" +] +py-version = 3.8 + +[tool.pylint.messages_control] +enable = [ + "bad-indentation", + "line-too-long" +] +disable = [ + "protected-access", + "fixme" +] + +[tool.pylint.format] +indent-string = ' ' +max-line-length = 120 From 0049a9217aec4542827bbd7f766247ff10c6abdd Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Tue, 4 Oct 2022 10:07:35 -0500 Subject: [PATCH 04/19] Migrate pytest to pyproject.toml --- pyproject.toml | 3 +++ pytest.ini | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 pytest.ini diff --git a/pyproject.toml b/pyproject.toml index 6e13133fa3..c17d126f14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,3 +33,6 @@ disable = [ [tool.pylint.format] indent-string = ' ' max-line-length = 120 + +[tool.pytest.ini_options] +asyncio_mode = "auto" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 2f4c80e307..0000000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -asyncio_mode = auto From 717fcbf1e5560ffcf01587a15c352682f95475ad Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 10:50:35 -0500 Subject: [PATCH 05/19] Add removals to MANIFEST This is needed because the setuptools_scm automatically adds all files tracked by git --- MANIFEST.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index e623df089b..747a5007bf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,3 +3,17 @@ include LICENSE include requirements.txt include discord/bin/*.dll include discord/py.typed + +prune .github +prune docs +prune examples +prune tests +exclude discord/bin/COPYING +exclude .flake8 +exclude .gitignore +exclude .pre-commit-config.yaml +exclude .prettierrc +exclude .readthedocs.yml +exclude CHANGELOG.md +exclude FUNDING.yml +exclude requirements-dev.txt From a01588a5c997030eef608f9fa839283c36529bcd Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 10:52:28 -0500 Subject: [PATCH 06/19] Remove logic from setup.py This file remains in order to support older build environments, but only needs a single setup() call with no parameters --- setup.py | 126 +------------------------------------------------------ 1 file changed, 2 insertions(+), 124 deletions(-) diff --git a/setup.py b/setup.py index e0320894a3..7f1a1763ca 100644 --- a/setup.py +++ b/setup.py @@ -1,126 +1,4 @@ -import re - from setuptools import setup -# Requirements -requirements = [] -with open("requirements.txt") as f: - requirements = f.read().splitlines() - -# Version Info -version = "" -with open("discord/__init__.py") as f: - - search = re.search( - r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE - ) - - if search is not None: - version = search.group(1) - - else: - raise RuntimeError("Could not grab version string") - -if not version: - raise RuntimeError("version is not set") - -if version.endswith(("a", "b", "rc")): - # append version identifier based on commit count - try: - import subprocess - - p = subprocess.Popen( - ["git", "rev-list", "--count", "HEAD"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - out, err = p.communicate() - if out: - version += out.decode("utf-8").strip() - p = subprocess.Popen( - ["git", "rev-parse", "--short", "HEAD"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - out, err = p.communicate() - if out: - version += f"+g{out.decode('utf-8').strip()}" - except Exception: - pass - -# README -readme = "" -with open("README.rst") as f: - readme = f.read() - -# Extra Requirements -# Ex: pip install py-cord[voice] or [speed] -extras_require = { - "voice": ["PyNaCl>=1.3.0,<1.6"], - "docs": [ - "sphinx==4.5.0", - "sphinxcontrib_trio==1.1.2", - "sphinxcontrib-websupport", - "myst-parser", - ], - "speed": [ - "orjson>=3.5.4", - "aiodns>=1.1", - "Brotlipy", - "cchardet", - ], -} - -# Folders And Such Included -packages = [ - "discord", - "discord.types", - "discord.sinks", - "discord.ui", - "discord.webhook", - "discord.commands", - "discord.ext.commands", - "discord.ext.tasks", - "discord.ext.pages", - "discord.ext.bridge", -] - - -setup( - name="py-cord", - author="Pycord Development", - url="https://pycord.dev/github", - project_urls={ - "Changelog": "https://github.com/Pycord-Development/pycord/blob/master/CHANGELOG.md", - "Website": "https://pycord.dev", - "Documentation": "https://docs.pycord.dev/en/master/", - "Issue tracker": "https://github.com/Pycord-Development/pycord/issues", - }, - version=version, - packages=packages, - license="MIT", - description="A Python wrapper for the Discord API", - long_description=readme, - long_description_content_type="text/x-rst", - include_package_data=True, - install_requires=requirements, - extras_require=extras_require, - python_requires=">=3.8.0", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "License :: OSI Approved :: MIT License", - "Intended Audience :: Developers", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Internet", - "Topic :: Software Development :: Libraries", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Utilities", - "Typing :: Typed", - ], - test_suite="tests", # Test Folder For Workflows -) +if __name__ == "__main__": + setup() From 748ce2417f802bd4db84b551b3bd94b002614809 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 11:11:16 -0500 Subject: [PATCH 07/19] Add project metadata to pyproject.toml --- pyproject.toml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c17d126f14..75569297ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,81 @@ +[build-system] +requires = [ + "setuptools==65.4.1", + "setuptools-scm==7.0.5" +] +build-backend = "setuptools.build_meta" + +[project] +name = "py-cord" +authors = [ + {name = "Pycord Development"} +] +description = "A Python wrapper for the Discord API" +readme = "README.rst" +requires-python = ">=3.8" +license = {text = "MIT"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Developers", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Internet", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Utilities", + "Typing :: Typed", +] +dynamic = ["version", "dependencies"] + +[project.urls] +Homepage = "https://pycord.dev" +Changelog = "https://github.com/Pycord-Development/pycord/blob/master/CHANGELOG.md" +Source = "https://github.com/Pycord-Development/pycord" +Documentation = "https://docs.pycord.dev" +Tracker = "https://github.com/Pycord-Development/pycord/issues" +Funding = "https://patreon.com/pycord" + +[project.optional-dependencies] +voice = [ + "PyNaCl>=1.3.0,<1.6", +] +docs = [ + "sphinx==4.5.0", + "sphinxcontrib_trio==1.1.2", + "sphinxcontrib-websupport", + "myst-parser", +] +speed = [ + "orjson>=3.5.4", + "aiodns>=1.1", + "Brotlipy", + "cchardet", +] + +[tool.setuptools] +packages = [ + "discord", + "discord.types", + "discord.sinks", + "discord.ui", + "discord.webhook", + "discord.commands", + "discord.ext.commands", + "discord.ext.tasks", + "discord.ext.pages", + "discord.ext.bridge", +] + +[tool.setuptools.dynamic] +dependencies = {file = "requirements.txt"} + +[tool.setuptools_scm] + [tool.black] target-version = ['py38', 'py39', 'py310', 'py311'] From d51cb5d600c4d64429a01247c7d10f0ff0433c26 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 11:12:23 -0500 Subject: [PATCH 08/19] Update runtime version discovery This now supports the new versioning system with setuptools_scm --- discord/__init__.py | 15 +------- discord/_version.py | 89 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 discord/_version.py diff --git a/discord/__init__.py b/discord/__init__.py index 3929fc5e3e..3bb8d1beaa 100644 --- a/discord/__init__.py +++ b/discord/__init__.py @@ -17,9 +17,9 @@ __path__ = __import__("pkgutil").extend_path(__path__, __name__) import logging -from typing import Literal, NamedTuple from . import abc, opus, sinks, ui, utils +from ._version import VersionInfo, __version__, version_info from .activity import * from .appinfo import * from .asset import * @@ -66,17 +66,4 @@ from .welcome_screen import * from .widget import * - -class VersionInfo(NamedTuple): - major: int - minor: int - micro: int - releaselevel: Literal["alpha", "beta", "candidate", "final"] - serial: int - - -version_info: VersionInfo = VersionInfo( - major=2, minor=2, micro=0, releaselevel="final", serial=0 -) - logging.getLogger(__name__).addHandler(logging.NullHandler()) diff --git a/discord/_version.py b/discord/_version.py new file mode 100644 index 0000000000..37022a70a2 --- /dev/null +++ b/discord/_version.py @@ -0,0 +1,89 @@ +import re +import warnings +from datetime import date +from importlib.metadata import PackageNotFoundError, version + +__all__ = ("__version__", "VersionInfo", "version_info") + +from typing import Literal, NamedTuple, Optional + +from discord.utils import deprecated + +try: + __version__ = version("py-cord") + print("Set version") +except PackageNotFoundError: + # Package is not installed + try: + from setuptools_scm import get_version # type: ignore[import] + + __version__ = get_version() + print("set version") + except ImportError: + # setuptools_scm is not installed + __version__ = "0.0.0" + warnings.warn( + "Package is not installed, and setuptools_scm is not installed. " + f"As a fallback, {__name__}.__version__ will be set to {__version__}", + RuntimeWarning, + stacklevel=2, + ) + + +class VersionInfo(NamedTuple): + major: int + minor: int + micro: int + release_level: Literal["alpha", "beta", "candidate", "final"] + serial: int + build: int | None = None + commit: str | None = None + date: Optional[date] = None + + @property + @deprecated + def releaselevel(self) -> Literal["alpha", "beta", "candidate", "final"]: + return self.release_level + + +version_regex = re.compile( + r"^(?P\d+)(?:\.(?P\d+))?(?:\.(?P\d+))?" + r"(?:(?Prc|a|b)(?P\d+))?" + r"(?:\.dev(?P\d+))?" + r"(?:\+(?:(?:g(?P[a-fA-F0-9]{8})\.d(?P\d{4}\d{2}\d{2}))|d(?P\d{4}\d{2}\d{2})))?$" +) + +raw_info = version_regex.match(__version__).groupdict() + +level_info: Literal["alpha", "beta", "candidate", "final"] + +if raw_info["level"] == "a": + level_info = "alpha" +elif raw_info["level"] == "b": + level_info = "beta" +elif raw_info["level"] == "rc": + level_info = "candidate" +elif raw_info["level"] is None: + level_info = "final" +else: + raise RuntimeError("Invalid release level") + +if (raw_date := raw_info["date"] or raw_info["date1"]) is not None: + date_info = date( + int(raw_date[:4]), + int(raw_date[4:6]), + int(raw_date[6:]), + ) +else: + date_info = None + +version_info: VersionInfo = VersionInfo( + major=raw_info["major"], + minor=raw_info["minor"], + micro=raw_info["patch"], + release_level=level_info, + serial=raw_info["serial"], + build=raw_info["build"], + commit=raw_info["commit"], + date=date_info, +) From 9e393ded3a35d2499114d0098eba7e1d4e53cf6a Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 11:15:02 -0500 Subject: [PATCH 09/19] Update deprecated info --- discord/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/_version.py b/discord/_version.py index 37022a70a2..2bfb4f58c5 100644 --- a/discord/_version.py +++ b/discord/_version.py @@ -41,7 +41,7 @@ class VersionInfo(NamedTuple): date: Optional[date] = None @property - @deprecated + @deprecated("release_level", "2.3") def releaselevel(self) -> Literal["alpha", "beta", "candidate", "final"]: return self.release_level From a2e8568dd9c9516e1dd22181c670f971ad25ca6c Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 11:36:53 -0500 Subject: [PATCH 10/19] Add future import and license --- discord/_version.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/discord/_version.py b/discord/_version.py index 2bfb4f58c5..693cf2aed5 100644 --- a/discord/_version.py +++ b/discord/_version.py @@ -1,3 +1,29 @@ +""" +The MIT License (MIT) + +Copyright (c) 2015-2021 Rapptz +Copyright (c) 2021-present Pycord Development + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +""" +from __future__ import annotations + import re import warnings from datetime import date @@ -5,7 +31,7 @@ __all__ = ("__version__", "VersionInfo", "version_info") -from typing import Literal, NamedTuple, Optional +from typing import Literal, NamedTuple from discord.utils import deprecated @@ -38,7 +64,7 @@ class VersionInfo(NamedTuple): serial: int build: int | None = None commit: str | None = None - date: Optional[date] = None + date: date | None = None @property @deprecated("release_level", "2.3") From a246ae9683ce6a4254d70cf187a754109a7206f5 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 11:37:31 -0500 Subject: [PATCH 11/19] Remove debug lines --- discord/_version.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/discord/_version.py b/discord/_version.py index 693cf2aed5..39436c370b 100644 --- a/discord/_version.py +++ b/discord/_version.py @@ -37,14 +37,12 @@ try: __version__ = version("py-cord") - print("Set version") except PackageNotFoundError: # Package is not installed try: from setuptools_scm import get_version # type: ignore[import] __version__ = get_version() - print("set version") except ImportError: # setuptools_scm is not installed __version__ = "0.0.0" From 15fb107e31c784dc8aa3b3fd3770af0df2f1228c Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 12:18:36 -0500 Subject: [PATCH 12/19] Use star import --- discord/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/__init__.py b/discord/__init__.py index 3bb8d1beaa..868b80c500 100644 --- a/discord/__init__.py +++ b/discord/__init__.py @@ -19,7 +19,7 @@ import logging from . import abc, opus, sinks, ui, utils -from ._version import VersionInfo, __version__, version_info +from ._version import * from .activity import * from .appinfo import * from .asset import * From 51b0fb8c4ce7eb164797ea0c4e9bbdfed19776ec Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 21:51:38 -0500 Subject: [PATCH 13/19] Remove version variable --- discord/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/discord/__init__.py b/discord/__init__.py index 484677f597..7c1c2f1e66 100644 --- a/discord/__init__.py +++ b/discord/__init__.py @@ -12,7 +12,6 @@ __author__ = "Pycord Development" __license__ = "MIT" __copyright__ = "Copyright 2015-2021 Rapptz & Copyright 2021-present Pycord Development" -__version__ = "2.2.2" __path__ = __import__("pkgutil").extend_path(__path__, __name__) From b69a45828a75ae6e2083639f0ef002a13fc919c4 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 22:09:49 -0500 Subject: [PATCH 14/19] Fix docs --- docs/conf.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 590e8eccf9..b9dc673694 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,8 +12,8 @@ # serve to show the default. import os -import re import sys +from importlib.metadata import version as get_version # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -90,20 +90,16 @@ # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. - -version = "" -with open("../discord/__init__.py") as f: - version = re.search( - r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE - ).group(1) # The full version, including alpha/beta/rc tags. -release = version +release = get_version("py-cord") + +# The short X.Y version. +version = ".".join(release.split(".")[:2]) # This assumes a tag is available for final releases branch = ( - "master" if "a" in version or "b" in version or "rc" in version else f"v{version}" + "master" if "a" in version or "b" in version or "rc" in version else f"v{release}" ) # The language for content autogenerated by Sphinx. Refer to documentation From 3fb2a5cf414fcef07b116555ca235211bc8685c1 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 22:17:16 -0500 Subject: [PATCH 15/19] Relative import to prevent circular import --- discord/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/_version.py b/discord/_version.py index 39436c370b..f3c51afbcb 100644 --- a/discord/_version.py +++ b/discord/_version.py @@ -33,7 +33,7 @@ from typing import Literal, NamedTuple -from discord.utils import deprecated +from .utils import deprecated try: __version__ = version("py-cord") From 6e52188e23b94c41b3bc461874941a9d7e393a06 Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 22:17:59 -0500 Subject: [PATCH 16/19] Install package with docs --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3ae086301f..ee8b41b4c7 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install -U pip - pip install -U sphinx sphinxcontrib-trio aiohttp sphinxcontrib-websupport myst-parser + pip install ".[docs]" - name: Compile to html run: | cd docs From e9b7f146c946df034eb052ca4c67f59d7734e18a Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Wed, 5 Oct 2022 22:56:26 -0500 Subject: [PATCH 17/19] Fix circular import --- discord/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/discord/__init__.py b/discord/__init__.py index 7c1c2f1e66..8196c56e1c 100644 --- a/discord/__init__.py +++ b/discord/__init__.py @@ -17,8 +17,14 @@ import logging -from . import abc, opus, sinks, ui, utils +# We need __version__ to be imported first +# isort: off from ._version import * + +# isort: on + + +from . import abc, opus, sinks, ui, utils from .activity import * from .appinfo import * from .asset import * From ef1e51ee6c20709115154c16f29226310644f7de Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Thu, 6 Oct 2022 08:29:20 -0500 Subject: [PATCH 18/19] Fix regex bug --- discord/_version.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/discord/_version.py b/discord/_version.py index f3c51afbcb..a60a086015 100644 --- a/discord/_version.py +++ b/discord/_version.py @@ -74,10 +74,12 @@ def releaselevel(self) -> Literal["alpha", "beta", "candidate", "final"]: r"^(?P\d+)(?:\.(?P\d+))?(?:\.(?P\d+))?" r"(?:(?Prc|a|b)(?P\d+))?" r"(?:\.dev(?P\d+))?" - r"(?:\+(?:(?:g(?P[a-fA-F0-9]{8})\.d(?P\d{4}\d{2}\d{2}))|d(?P\d{4}\d{2}\d{2})))?$" + r"(?:\+(?:(?:g(?P[a-fA-F0-9]{8})(?:\.d(?P\d{4}\d{2}\d{2})|))|d(?P\d{4}\d{2}\d{2})))?$" ) - -raw_info = version_regex.match(__version__).groupdict() +version_match = version_regex.match(__version__) +if version_match is None: + raise RuntimeError(f"Invalid version string: {__version__}") +raw_info = version_match.groupdict() level_info: Literal["alpha", "beta", "candidate", "final"] From 446a098f95d4e31f209cef2d785adf505ed4fdcd Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Thu, 6 Oct 2022 08:47:19 -0500 Subject: [PATCH 19/19] Short commit hash is 4-40 chars --- discord/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/_version.py b/discord/_version.py index a60a086015..8a1e28c691 100644 --- a/discord/_version.py +++ b/discord/_version.py @@ -74,7 +74,7 @@ def releaselevel(self) -> Literal["alpha", "beta", "candidate", "final"]: r"^(?P\d+)(?:\.(?P\d+))?(?:\.(?P\d+))?" r"(?:(?Prc|a|b)(?P\d+))?" r"(?:\.dev(?P\d+))?" - r"(?:\+(?:(?:g(?P[a-fA-F0-9]{8})(?:\.d(?P\d{4}\d{2}\d{2})|))|d(?P\d{4}\d{2}\d{2})))?$" + r"(?:\+(?:(?:g(?P[a-fA-F0-9]{4,40})(?:\.d(?P\d{4}\d{2}\d{2})|))|d(?P\d{4}\d{2}\d{2})))?$" ) version_match = version_regex.match(__version__) if version_match is None: