Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ci & code quality #76

Merged
merged 12 commits into from Dec 13, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .flake8
@@ -1,4 +1,5 @@
[flake8]
min_python_version = 3.10
count = true
max-line-length = 120
show_source = True
Expand Down Expand Up @@ -40,6 +41,8 @@ ignore =
E722
# W503: line break before binary operator
W503
# E203: whitespace before ':'
E203

per-file-ignores =
# imported but unused
Expand All @@ -61,4 +64,4 @@ exclude =

accept-encodings = utf-8
max-complexity = 19
docstring-convention = numpy
docstring-convention = numpy
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto
12 changes: 6 additions & 6 deletions .github/dependabot.yml
@@ -1,10 +1,10 @@
version: 2
updates:
- package-ecosystem: 'pip'
directory: '/'
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: 'daily'
- package-ecosystem: 'github-actions'
directory: '/'
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: 'daily'
interval: "daily"
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -15,4 +15,5 @@ test.py
.nox/
*.inv
ci.py
.env
.env
testing/
91 changes: 91 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,91 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
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.1.0
hooks:
- id: pyupgrade
args: [--py310-plus]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/odwyersoftware/brunette
rev: 0.2.7
hooks:
- id: brunette
# See https://github.com/psf/black/issues/2188#issuecomment-1289317647 for why we can't use the --preview flag.
args: [--safe, --quiet, --single-quotes]
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker
rev: 1.0.1
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"]
# - repo: https://github.com/myint/rstcheck
# rev: "v5.0.0"
# hooks:
# - id: rstcheck
# args: ["--ignore-roles=func,class,mod", "--report=warning"]
# types: [text]
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.950
# hooks:
# - id: mypy

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.3
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: 93b15ca # TODO: Change this when v8.0 is released
hooks:
- id: pydocstringformatter
args:
[
--style=numpydoc,
--no-numpydoc-name-type-spacing,
--no-final-period,
--no-capitalize-first-letter,
]
3 changes: 3 additions & 0 deletions .prettierrc
@@ -0,0 +1,3 @@
proseWrap: always
printWidth: 88
endOfLine: auto
17 changes: 8 additions & 9 deletions .readthedocs.yml
Expand Up @@ -6,15 +6,14 @@ build:
tools:
python: "3.10"


python:
install:
- method: pip
path: .
extra_requirements:
- docs
install:
- method: pip
path: .
extra_requirements:
- docs

sphinx:
configuration: docs/conf.py
fail_on_warning: false
builder: html
configuration: docs/conf.py
fail_on_warning: false
builder: html
Empty file added CHANGELOG.md
Empty file.
3 changes: 1 addition & 2 deletions LICENSE
@@ -1,6 +1,5 @@
MIT License

Copyright (c) 2021-present VincentRPS
Copyright (c) 2022-present Pycord

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -19,4 +18,4 @@ 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.
SOFTWARE.
18 changes: 17 additions & 1 deletion MANIFEST.in
@@ -1,4 +1,20 @@
include README.rst
include LICENSE
include requirements.txt
include pycord/bin/*.dll
include pycord/py.typed
include pycord/banner.txt
include pycord/bin/*.dll

prune .github
prune docs
prune examples
prune tests
exclude pycord/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
29 changes: 20 additions & 9 deletions README.md
Expand Up @@ -15,19 +15,23 @@
The API Wrapper for <b>Modern Discord Bots.</b>
</p>

Welcome! This is the repository for the pre-alpha and heavy conception next major version of Pycord.
Welcome! This is the repository for the pre-alpha and heavy conception next major
version of Pycord.

## Installation

Pycord v3 is not yet published onto PyPi, so for now you'll have to install via git.
To do this, you should install [git](https://git-scm.com) if not already installed.
Pycord v3 is not yet published onto PyPi, so for now you'll have to install via git. To
do this, you should install [git](https://git-scm.com) if not already installed.

An automatic install should look something like

```sh
pip install -U git+https://github.com/pycord-development/pycord-v3
```

If instead, you wanted to do a manual install (incase of something like development), you could do the following
If instead, you wanted to do a manual install (incase of something like development),
you could do the following

```sh
# Git command
git clone https://github.com/pycord-development/pycord-v3
Expand All @@ -38,16 +42,23 @@ If instead, you wanted to do a manual install (incase of something like developm

## Stability

While we are working and striving for stability throughout v3, its still quite a new library so breakages can still happen especially with us still being in a pre-alpha stage.
While we are working and striving for stability throughout v3, its still quite a new
library so breakages can still happen especially with us still being in a pre-alpha
stage.

## Breaking Changes

v3 is a new **major version** of pycord, meaning breaking changes have occurred. Although a much larger amount than v2, v3 introduces a new paradigm for Pycord bots and ensures code quality for developers (of the library.)
v3 is a new **major version** of pycord, meaning breaking changes have occurred.
Although a much larger amount than v2, v3 introduces a new paradigm for Pycord bots and
ensures code quality for developers (of the library.)

Every aspect of v2 has been remade and improved upon to make your development experience quicker, easier, and mucho gracias.
Breaking changes are everywhere, from typings to Python version increases.
Every aspect of v2 has been remade and improved upon to make your development experience
quicker, easier, and mucho gracias. Breaking changes are everywhere, from typings to
Python version increases.

That being said, if you want to move your bot to v3 you'll have to rewrite it. We've made sure to make the rewriting experience easier though, providing less boilerplate than v2 and letting you do anything in smaller snippets.
That being said, if you want to move your bot to v3 you'll have to rewrite it. We've
made sure to make the rewriting experience easier though, providing less boilerplate
than v2 and letting you do anything in smaller snippets.

## Code Example

Expand Down
5 changes: 3 additions & 2 deletions docs/conf.py
Expand Up @@ -10,8 +10,9 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'Pycord'
copyright = '2022, Pycord'
author = 'VincentRPS'

copyright = '2021-present, Pycord Development'
author = 'Pycord Development'
release = '3.0.0'

# -- General configuration ---------------------------------------------------
Expand Down
11 changes: 9 additions & 2 deletions examples/superspeed_rate_limiting.py
Expand Up @@ -13,15 +13,22 @@ async def spam_channels() -> None:
channels: list[dict[str, Any]] = []

tasks: list[asyncio.Task] = [
api.request('POST', pycord.Route('/guilds/{guild_id}/channels', guild_id=GUILD_ID), {'name': 'rate-limit-test'})
api.request(
'POST',
pycord.Route('/guilds/{guild_id}/channels', guild_id=GUILD_ID),
{'name': 'rate-limit-test'},
)
for _ in range(50)
]

channels = await asyncio.gather(*tasks)
tasks.clear()

tasks.extend(
api.request('DELETE', pycord.Route('/channels/{channel_id}', channel_id=channel['id'])) for channel in channels
api.request(
'DELETE', pycord.Route('/channels/{channel_id}', channel_id=channel['id'])
)
for channel in channels
)

await asyncio.gather(*tasks)
Expand Down
2 changes: 1 addition & 1 deletion pycord/__init__.py
Expand Up @@ -3,7 +3,7 @@
~~~~~~
Python's Intuitive Discord API Wrapper

:copyright: 2021-present VincentRPS
:copyright: 2021-present Pycord Development
:license: MIT
"""
from ._about import *
Expand Down
4 changes: 1 addition & 3 deletions pycord/__main__.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# cython: language_level=3
# Copyright (c) 2021-present VincentRPS
# Copyright (c) 2022-present Pycord Development
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -28,7 +26,7 @@


def main() -> None:
version = pycord.__version__ # type: ignore
version = pycord.__version__
python_version = platform.python_version()
sys.stderr.write(f'Running on Pycord Version {version},')
sys.stderr.write(f' with Python version {python_version}.')
Expand Down
10 changes: 6 additions & 4 deletions pycord/_about.py
Expand Up @@ -2,9 +2,9 @@
import typing

__title__: str = 'pycord'
__author__: str = 'VincentRPS & Pycord'
__author__: str = 'Pycord Development'
__license__: str = 'MIT'
__copyright__: str = 'Copyright 2021-present VincentRPS'
__copyright__: str = 'Copyright 2021-present Pycord Development'
__version__: str = '3.0.0'
__git_sha1__: str = 'HEAD'

Expand All @@ -17,11 +17,13 @@ class VersionInfo(typing.NamedTuple):
serial: int


version_info: VersionInfo = VersionInfo(major=3, minor=0, micro=0, releaselevel='alpha', serial=0)
version_info: VersionInfo = VersionInfo(
major=3, minor=0, micro=0, releaselevel='alpha', serial=0
)

logging.getLogger(__name__).addHandler(logging.NullHandler())

__all__: typing.List[str] = [
__all__: list[str] = [
'__title__',
'__author__',
'__license__',
Expand Down
6 changes: 4 additions & 2 deletions pycord/api/__init__.py
Expand Up @@ -3,12 +3,12 @@
~~~~~~~~~~
Implementation of the Discord API.

:copyright: 2021-present VincentRPS
:copyright: 2021-present Pycord Development
:license: MIT
"""
import logging
import sys
from typing import Any, Optional
from typing import Any

from aiohttp import BasicAuth, ClientSession, __version__ as aiohttp_version

Expand Down Expand Up @@ -60,6 +60,7 @@ async def request(
self,
method: str,
route: BaseRoute,

data: Optional[dict[str, Any]] = None,
*,
reason: Optional[str] = None,
Expand Down Expand Up @@ -95,6 +96,7 @@ async def request(
headers=headers,
proxy=self._proxy,
proxy_auth=self._proxy_auth,

params=query_params,
)
_log.debug(f'Received back {await r.text()}')
Expand Down
2 changes: 1 addition & 1 deletion pycord/api/execution/__init__.py
Expand Up @@ -3,7 +3,7 @@
~~~~~~~~~~~~~~~~
Rate Limit execution for the Discord API

:copyright: 2021-present VincentRPS
:copyright: 2021-present Pycord Development
:license: MIT
"""
from .executer import *