From f38f253de0bc379b896c7f9b3a7f5e154fb83323 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:28:11 +0300 Subject: [PATCH 01/14] Cleanup workflows - Added Bandit - Added unimport, isort, flynt - Added PyRight - Enabled preview mode on Bandit --- .github/workflows/autoblack.yml | 30 --------------------- .github/workflows/bandit.yml | 26 ++++++++++++++++++ .github/workflows/lint.yml | 47 +++++++++++++++++++++++++++++++++ .github/workflows/pylint.yml | 33 ++++++++++++----------- .github/workflows/pyright.yml | 28 ++++++++++++++++++++ pyproject.toml | 46 +++++++++++++++++++++++++++++++- 6 files changed, 164 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/autoblack.yml create mode 100644 .github/workflows/bandit.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/pyright.yml diff --git a/.github/workflows/autoblack.yml b/.github/workflows/autoblack.yml deleted file mode 100644 index 6b00ae9..0000000 --- a/.github/workflows/autoblack.yml +++ /dev/null @@ -1,30 +0,0 @@ -# GitHub Action that uses Black to reformat the Python code in an incoming pull request. -# If all Python code in the pull request is compliant with Black then this Action does nothing. -# Othewrwise, Black is run and its changes are committed back to the incoming pull request. -# https://github.com/cclauss/autoblack - -name: autoblack -on: [pull_request] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: Install Black - run: pip install black - - name: Run black --check . - run: black --check . - - name: If needed, commit black changes to the pull request - if: failure() - run: | - black . - git config --global user.name 'autoblack' - git config --global user.email 'cclauss@users.noreply.github.com' - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git checkout $GITHUB_HEAD_REF - git commit -am "fixup: Format Python code with Black" - git push diff --git a/.github/workflows/bandit.yml b/.github/workflows/bandit.yml new file mode 100644 index 0000000..d8a0277 --- /dev/null +++ b/.github/workflows/bandit.yml @@ -0,0 +1,26 @@ +name: Bandit + +on: [ pull_request, push ] + +jobs: + build: + if: github.event.pull_request.user.type != 'Bot' + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.8', '3.9', '3.10' ] + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Bandit + run: pip install -U pip bandit + + - name: Run Bandit + run: bandit --recursive ./ diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c2c5235 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,47 @@ +name: Lint + +on: [ pull_request, push ] + +jobs: + build: + if: github.event.pull_request.user.type != 'Bot' + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.8', '3.9', '3.10' ] + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Unimport, Isort, Black, and Flynt + run: pip install -U pip unimport isort black flynt + + - name: Run Unimport + continue-on-error: true + run: unimport ./ --ignore-init --gitignore -r + + - name: Run Isort + run: isort ./ + + - name: Run Black + run: black ./ + + - name: Run Flynt + run: flynt ./ -tc + + - name: Setup Git + run: git config user.name "Automated Linter" + + - name: Push To GitHub + continue-on-error: true + run: | + git pull + git add ./ + git commit --reuse-message=HEAD + git push diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 383e65c..848a02a 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -1,23 +1,26 @@ -name: Pylint +name: PyLint -on: [push] +on: [ pull_request, push ] jobs: build: + if: github.event.pull_request.user.type != 'Bot' runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: [ '3.8', '3.9', '3.10' ] + steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install PyLint + run: pip install -U pip pylint + + - name: Run PyLint + run: pylint $(git ls-files '*.py') diff --git a/.github/workflows/pyright.yml b/.github/workflows/pyright.yml new file mode 100644 index 0000000..920383b --- /dev/null +++ b/.github/workflows/pyright.yml @@ -0,0 +1,28 @@ +name: PyRight + +on: [ pull_request, push ] + +jobs: + build: + if: github.event.pull_request.user.type != 'Bot' + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.8', '3.9', '3.10' ] + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install PyRight & Dependencies + run: | + pip install -U pip pyright + pip install -Ur requirements.txt + + - name: Run PyRight + run: pyright ./ diff --git a/pyproject.toml b/pyproject.toml index 06168bb..dc4a088 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,47 @@ [tool.black] line-length = 125 -skip-string-normalization = true \ No newline at end of file +skip-string-normalization = true +preview = true # better formatting basically + +[tool.isort] +line_length = 125 +combine_as_imports = true +combine_star = true + +[tool.pyright] +typeCheckingMode = "basic" +strictListInference = true +strictDictionaryInference = true +strictSetInference = true + +# explicity enabling is better than making it strict and disabling stuff +reportMissingModuleSource = "error" +reportAssertAlwaysTrue = "error" +reportInvalidStringEscapeSequence = "error" +reportInvalidTypeVarUse = "error" +reportSelfClsParameterName = "error" +reportUnsupportedDunderAll = "error" +reportUnusedExpression = "error" +reportWildcardImportFromLibrary = "error" +reportConstantRedefinition = "error" +reportDuplicateImport = "error" +reportImportCycles = "error" +reportIncompatibleVariableOverride = "error" +reportIncompleteStub = "error" +reportInconsistentConstructor = "error" +reportInvalidStubStatement = "error" +reportMatchNotExhaustive = "error" +reportMissingParameterType = "error" +reportTypeCommentUsage = "error" +reportUnnecessaryCast = "error" +reportUnnecessaryComparison = "error" +reportUnnecessaryIsInstance = "error" +reportUnusedClass = "error" +reportUnusedVariable = "error" +reportUntypedBaseClass = "error" +reportUntypedClassDecorator = "error" +reportUntypedFunctionDecorator = "error" +reportUntypedNamedTuple = "error" +reportCallInDefaultInitializer = "error" +reportPropertyTypeMismatch = "error" +reportUnnecessaryTypeIgnoreComment = "error" \ No newline at end of file From ad784f87cb8cadfc52a55607a7122b7245782e4e Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:41:25 +0300 Subject: [PATCH 02/14] Add Issue Templates - Added Bug Report Template - Added Feature Request Template - Added Issue Menu Config --- .github/ISSUE_TEMPLATE/bug_report.yml | 57 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 4 ++ .github/ISSUE_TEMPLATE/feature_request.yml | 46 +++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..767eaff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,57 @@ +name: Bug Report +description: Report broken or incorrect behaviour +labels: + - bug +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out a bug. + If you want real-time support, consider joining our [Discord server](https://discord.gg/pTJfS4TkWe) instead. + + Please note that this form is for bugs only! + - type: input + attributes: + label: Summary + description: A simple summary of your bug report. + validations: + required: true + - type: textarea + attributes: + label: Reproduction Steps + description: What you do to make it happen? + validations: + required: true + - type: textarea + attributes: + label: Minimal Reproducible Code + description: A short snippet of code that showcases the bug. + render: Python + - type: textarea + attributes: + label: Expected Results + description: What did you expect to happen? + validations: + required: true + - type: textarea + attributes: + label: Actual Results + description: What actually happened? + validations: + required: true + - type: checkboxes + attributes: + label: Checklist + description: | + Let's make sure you've properly done due diligence when reporting this issue! + options: + - label: I have searched the open issues for duplicates. + required: true + - label: I have shown the entire traceback, if possible. + required: true + - label: I have removed my token from display, if visible. + required: true + - type: textarea + attributes: + label: Additional Context + description: If there is anything else to say, please do so here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..293fe3a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,4 @@ +contact_links: + - name: Discord Server + about: Use our official Discord server to ask for help and questions. + url: https://discord.gg/pTJfS4TkWe diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..efc3d71 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,46 @@ +name: Feature Request +description: Suggest a feature for this library +labels: + - enhancement +body: + - type: input + attributes: + label: Summary + description: A short summary of what your feature request is. + validations: + required: true + - type: dropdown + attributes: + multiple: false + label: What is the feature request for? + options: + - The library + - The documentation + validations: + required: true + - type: textarea + attributes: + label: The Problem + description: | + What problem is your feature trying to solve? + What becomes easier or possible when this feature is implemented? + validations: + required: true + - type: textarea + attributes: + label: The Ideal Solution + description: | + What is your ideal solution to the problem? + What would you like this feature to do? + validations: + required: true + - type: textarea + attributes: + label: The Current Solution + description: What is the current solution to the problem, if any? + validations: + required: false + - type: textarea + attributes: + label: Additional Context + description: If there is anything else to say, please do so here. From 3821f1bda3691d2ea105184e1e760c34c30f3dda Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:43:32 +0300 Subject: [PATCH 03/14] Add Spacing to Issue Templates --- .github/ISSUE_TEMPLATE/bug_report.yml | 10 ++++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 767eaff..07d3a50 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,7 +1,10 @@ name: Bug Report + description: Report broken or incorrect behaviour + labels: - bug + body: - type: markdown attributes: @@ -10,35 +13,41 @@ body: If you want real-time support, consider joining our [Discord server](https://discord.gg/pTJfS4TkWe) instead. Please note that this form is for bugs only! + - type: input attributes: label: Summary description: A simple summary of your bug report. validations: required: true + - type: textarea attributes: label: Reproduction Steps description: What you do to make it happen? validations: required: true + - type: textarea attributes: label: Minimal Reproducible Code description: A short snippet of code that showcases the bug. render: Python + - type: textarea attributes: label: Expected Results description: What did you expect to happen? validations: required: true + - type: textarea attributes: label: Actual Results description: What actually happened? validations: required: true + - type: checkboxes attributes: label: Checklist @@ -51,6 +60,7 @@ body: required: true - label: I have removed my token from display, if visible. required: true + - type: textarea attributes: label: Additional Context diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index efc3d71..0239552 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,7 +1,10 @@ name: Feature Request + description: Suggest a feature for this library + labels: - enhancement + body: - type: input attributes: @@ -9,6 +12,7 @@ body: description: A short summary of what your feature request is. validations: required: true + - type: dropdown attributes: multiple: false @@ -18,6 +22,7 @@ body: - The documentation validations: required: true + - type: textarea attributes: label: The Problem @@ -26,6 +31,7 @@ body: What becomes easier or possible when this feature is implemented? validations: required: true + - type: textarea attributes: label: The Ideal Solution @@ -34,12 +40,14 @@ body: What would you like this feature to do? validations: required: true + - type: textarea attributes: label: The Current Solution description: What is the current solution to the problem, if any? validations: required: false + - type: textarea attributes: label: Additional Context From fad5b71bf76e17c8d1d466af465a9d58e05111b3 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:44:32 +0300 Subject: [PATCH 04/14] Make LICENSE history format correct --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 4f35413..33980cc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 - Present VarMonke and sudosnok +Copyright (c) 2022-present VarMonke and sudosnok Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From fcf2897e46a210e1585b644265a12ecd4a1e70d3 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:50:16 +0300 Subject: [PATCH 05/14] Cleanup README --- README.rst | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index c99efab..05d72b5 100644 --- a/README.rst +++ b/README.rst @@ -16,16 +16,16 @@ Key Features Installing ---------- -**Python 3.8 or higher** +**Python 3.8 or higher is required to run the library** -To install the library, run the following command +To install the library, run the following command: .. code:: sh - #Linux/macOS + # On Linux or MacOS python3 -m pip install -U git+https://github.com/VarMonke/Github-Api-Wrapper - #Windows + # On Windows py -m pip install -U git+https://github.com/VarMonke/Github-Api-Wrapper Quick Example @@ -38,18 +38,21 @@ Quick Example async def main(): client = await github.GHClient() - return await client.get_user(user='GithubPythonBot') - user = asyncio.run(main()) - print(user) - print(user.html_url) + user = await client.get_user(user='GithubPythonBot') + + print(user) + print(user.html_url) + + asyncio.run(main()) .. code:: sh - #Output + # Output https://github.com/GithubPythonBot Links ----- -`Discord Server `_ \ No newline at end of file +- `Discord Server `_ +- `GitHub API Documentation `_ From fb95fe6bab98b88b2efb016175c151d3a48a090b Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:54:22 +0300 Subject: [PATCH 06/14] Cleanup setup.py --- setup.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/setup.py b/setup.py index 767c03d..73e2610 100644 --- a/setup.py +++ b/setup.py @@ -2,20 +2,12 @@ import re from pathlib import Path from setuptools import setup -with open('requirements.txt') as f: - requirements = f.read().splitlines() - -path = Path(__file__).parent / "github" / "__init__.py" -version = re.search(r'\d[.]\d[.]\d', path.read_text()).group(0) # type: ignore +ROOT_DIR = Path(__file__).parent packages = [ 'github', ] -readme = '' -with open('README.rst') as f: - readme = f.read() - extras_require = { 'docs': [ 'sphinx==4.4.0', @@ -29,11 +21,11 @@ setup( name='github', author='VarMonke & sudosnok', url='https://github.com/VarMonke/Github-Api-Wrapper', - version=version, + version=re.search(r'\d[.]\d[.]\d', (ROOT_DIR / "github" / "__init__.py").read_text())[0], packages=packages, license='MIT', description='An asynchronous python wrapper around the GitHub API', - long_description=readme, - install_requires=requirements, + long_description=(ROOT_DIR / "README.rst").read_text(), + install_requires=(ROOT_DIR / "requirements.txt").read_text().splitlines(), python_requires='>=3.8.0', ) From 1dffb9f9f9e7e3a95daa9e8686827bc218154563 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:55:30 +0300 Subject: [PATCH 07/14] Fix Licenses --- assets/LICENSE | 2 +- docs/LICENSE | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/LICENSE b/assets/LICENSE index dede212..6ea3437 100644 --- a/assets/LICENSE +++ b/assets/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 - Present Jess, VarMonke and sudosnok +Copyright (c) 2022-present Jess, VarMonke and sudosnok Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/docs/LICENSE b/docs/LICENSE index 6123073..71176f5 100644 --- a/docs/LICENSE +++ b/docs/LICENSE @@ -1,7 +1,7 @@ MIT License -Copyright (c) 2015-present Rapptz -Copyright (c) 2022 - Present Rapptz, VarMonke and sudosnok +Copyright (c) 2015-2022 Rapptz +Copyright (c) 2022-present VarMonke and sudosnok Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From d00f1aa69608d2bbea0e702a22e9aa479fa9d41c Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:59:03 +0300 Subject: [PATCH 08/14] Add credits to issue templates --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 ++ .github/ISSUE_TEMPLATE/feature_request.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 07d3a50..13630b6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,3 +1,5 @@ +# Credits to most of this template go to Rapptz (https://github.com/Rapptz) +# as this was taken from the discord.py repository (https://github.com/Rapptz/discord.py/blob/868476c99963e72aa529ed6203f86ef529a2c1f1/.github/ISSUE_TEMPLATE/bug_report.yml) name: Bug Report description: Report broken or incorrect behaviour diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 0239552..a26a61f 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,3 +1,5 @@ +# Credits to most of this template go to Rapptz (https://github.com/Rapptz) +# as this was taken from the discord.py repository (https://github.com/Rapptz/discord.py/blob/868476c99963e72aa529ed6203f86ef529a2c1f1/.github/ISSUE_TEMPLATE/feature_request.yml) name: Feature Request description: Suggest a feature for this library From ccf371dc077c15bb07a57013bdbf95dac452300e Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:00:26 +0300 Subject: [PATCH 09/14] add PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d0e7d1d --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,14 @@ +## Summary + + + +## Checklist + + + +- [ ] If code changes were made then they have been tested. + - [ ] I have updated the documentation to reflect the changes. +- [ ] This PR fixes an issue. +- [ ] This PR adds something new (e.g. new method or parameters). +- [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed) +- [ ] This PR is **not** a code change (e.g. documentation, README, ...) From 54c4ea01e96b211a5d828ee71e085c3f629840a5 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:00:55 +0300 Subject: [PATCH 10/14] Fix line endings --- pyproject.toml | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dc4a088..18ff41f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,4 +44,4 @@ reportUntypedFunctionDecorator = "error" reportUntypedNamedTuple = "error" reportCallInDefaultInitializer = "error" reportPropertyTypeMismatch = "error" -reportUnnecessaryTypeIgnoreComment = "error" \ No newline at end of file +reportUnnecessaryTypeIgnoreComment = "error" diff --git a/setup.cfg b/setup.cfg index 0cd12b7..85b00d0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,4 +17,4 @@ project_urls = packages = find: python_requires = >=3.8 install_requires = - aiohttp == 3.8.1 \ No newline at end of file + aiohttp == 3.8.1 From f03fe71fd6a47f47f6238ddc50f8800058808781 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:02:04 +0300 Subject: [PATCH 11/14] Fix copyright year and format --- github/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/__init__.py b/github/__init__.py index cc62ecd..b8a0c61 100644 --- a/github/__init__.py +++ b/github/__init__.py @@ -4,7 +4,7 @@ __title__ = 'Github-Api-Wrapper' __authors__ = 'VarMonke', 'sudosnok' __version__ = '1.2.1' __license__ = 'MIT' -__copyright__ = 'Copyright (c) 2020 VarMonke & sudosnok' +__copyright__ = 'Copyright (c) 2022-present VarMonke & sudosnok' from .client import * from .objects import * From 0d10386c39db824f3e85725875e0b82c96454ca2 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:03:25 +0300 Subject: [PATCH 12/14] Update readthedocs version (might break stuff) --- .readthedocs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index a253e45..471139f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,4 +1,4 @@ -version: 1 +version: 2 sphinx: configuration: docs/conf.py @@ -6,7 +6,7 @@ sphinx: builder: html python: - version: 3.8 + version: '3.8' install: - method: pip path: . From 17b813532d1cfd004b89a2c51f8819a7ae22bda6 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:03:25 +0300 Subject: [PATCH 13/14] Update readthedocs version (might break stuff) --- docs/conf.py | 4 ++-- docs/extensions/attributetable.py | 3 ++- docs/extensions/builder.py | 2 +- docs/extensions/details.py | 6 ++--- docs/extensions/exception_hierarchy.py | 5 +--- docs/extensions/resourcelinks.py | 3 +-- github/__init__.py | 6 ++--- github/cache.py | 2 +- github/client.py | 18 +++++++-------- github/exceptions.py | 2 +- github/http.py | 32 +++++++++++--------------- github/objects.py | 21 +++++++++-------- github/urls.py | 32 +++++++++++++------------- setup.py | 1 + 14 files changed, 67 insertions(+), 70 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a33eb0e..0976050 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,7 @@ import logging -import sys import os import re +import sys # 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 @@ -85,7 +85,7 @@ with open('../github/__init__.py') as f: release = version # This assumes a tag is available for final releases -branch = 'master' if version.endswith('a') else 'v' + version +branch = 'master' if version.endswith('a') else f"v{version}" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/extensions/attributetable.py b/docs/extensions/attributetable.py index 3e1f36b..cebb4f0 100644 --- a/docs/extensions/attributetable.py +++ b/docs/extensions/attributetable.py @@ -1,8 +1,9 @@ from __future__ import annotations + import importlib import inspect import re -from typing import Dict, List, NamedTuple, Optional, Tuple, Sequence, TYPE_CHECKING +from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Sequence, Tuple from docutils import nodes from sphinx import addnodes diff --git a/docs/extensions/builder.py b/docs/extensions/builder.py index c686e74..00b4b6f 100644 --- a/docs/extensions/builder.py +++ b/docs/extensions/builder.py @@ -42,7 +42,7 @@ class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder): self.handle_page('genindex-all', genindexcontext, 'genindex.html') for (key, entries), count in zip(genindex, indexcounts): ctx = {'key': key, 'entries': entries, 'count': count, 'genindexentries': genindex} - self.handle_page('genindex-' + key, ctx, 'genindex-single.html') + self.handle_page(f"genindex-{key}", ctx, 'genindex-single.html') else: self.handle_page('genindex', genindexcontext, 'genindex.html') diff --git a/docs/extensions/details.py b/docs/extensions/details.py index e6b97c0..577ada4 100644 --- a/docs/extensions/details.py +++ b/docs/extensions/details.py @@ -1,7 +1,7 @@ -from docutils.parsers.rst import Directive -from docutils.parsers.rst import states, directives # type: ignore -from docutils.parsers.rst.roles import set_classes from docutils import nodes +from docutils.parsers.rst import directives # type: ignore +from docutils.parsers.rst import Directive +from docutils.parsers.rst.roles import set_classes class details(nodes.General, nodes.Element): diff --git a/docs/extensions/exception_hierarchy.py b/docs/extensions/exception_hierarchy.py index 6a70d10..2f3d433 100644 --- a/docs/extensions/exception_hierarchy.py +++ b/docs/extensions/exception_hierarchy.py @@ -1,8 +1,5 @@ -from docutils.parsers.rst import Directive -from docutils.parsers.rst import states, directives # type: ignore -from docutils.parsers.rst.roles import set_classes from docutils import nodes -from sphinx.locale import _ +from docutils.parsers.rst import Directive class exception_hierarchy(nodes.General, nodes.Element): diff --git a/docs/extensions/resourcelinks.py b/docs/extensions/resourcelinks.py index cb584a4..36e197e 100644 --- a/docs/extensions/resourcelinks.py +++ b/docs/extensions/resourcelinks.py @@ -4,11 +4,10 @@ from typing import Any, Dict, List, Tuple +import sphinx from docutils import nodes, utils from docutils.nodes import Node, system_message from docutils.parsers.rst.states import Inliner - -import sphinx from sphinx.application import Sphinx from sphinx.util.nodes import split_explicit_title from sphinx.util.typing import RoleFunction diff --git a/github/__init__.py b/github/__init__.py index b8a0c61..9f7931d 100644 --- a/github/__init__.py +++ b/github/__init__.py @@ -7,7 +7,7 @@ __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022-present VarMonke & sudosnok' from .client import * -from .objects import * -from .http import * -from .urls import * from .exceptions import * +from .http import * +from .objects import * +from .urls import * diff --git a/github/cache.py b/github/cache.py index 0585204..29d236e 100644 --- a/github/cache.py +++ b/github/cache.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections import deque -from typing import Any, Deque, Tuple, TypeVar, Dict +from typing import Any, Deque, Dict, Tuple, TypeVar __all__: Tuple[str, ...] = ('ObjectCache',) diff --git a/github/client.py b/github/client.py index 9289d0e..eac8627 100644 --- a/github/client.py +++ b/github/client.py @@ -2,29 +2,29 @@ from __future__ import annotations import functools -import aiohttp - from typing import ( + Any, Awaitable, Callable, - Literal, - Any, Coroutine, Dict, Generator, + List, + Literal, Optional, Tuple, - Union, - List, - overload, TypeVar, + Union, + overload, ) -from typing_extensions import Self, ParamSpec, Concatenate + +import aiohttp +from typing_extensions import Concatenate, ParamSpec, Self from . import exceptions from .cache import ObjectCache from .http import http -from .objects import Gist, Issue, Organization, Repository, User, File +from .objects import File, Gist, Issue, Organization, Repository, User __all__: Tuple[str, ...] = ('GHClient', 'Client') diff --git a/github/exceptions.py b/github/exceptions.py index 0b27540..60f791f 100644 --- a/github/exceptions.py +++ b/github/exceptions.py @@ -65,7 +65,7 @@ class Ratelimited(APIError): def __init__(self, reset_time: datetime.datetime): formatted = reset_time.strftime(r"%H:%M:%S %A, %d %b") - msg = "We're being ratelimited, wait until {}.\nAuthentication raises the ratelimit.".format(formatted) + msg = f"We're being ratelimited, wait until {formatted}.\nAuthentication raises the ratelimit." super().__init__(msg) diff --git a/github/http.py b/github/http.py index 8cf193d..8d54103 100644 --- a/github/http.py +++ b/github/http.py @@ -1,27 +1,21 @@ # == http.py ==# from __future__ import annotations -from asyncio.base_subprocess import ReadSubprocessPipeProto -from base64 import b64encode import json +import platform import re from datetime import datetime from types import SimpleNamespace -from typing import Any, Dict, Literal, NamedTuple, Optional, Type, Tuple, Union, List -from typing_extensions import TypeAlias, reveal_type -import platform +from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Type, Union import aiohttp +from typing_extensions import TypeAlias -from .exceptions import * -from .exceptions import GistNotFound, RepositoryAlreadyExists, MissingPermissions -from .exceptions import FileAlreadyExists -from .exceptions import ResourceAlreadyExists -from .exceptions import Ratelimited -from .objects import User, Gist, Repository, File, bytes_to_b64 -from .urls import * from . import __version__ +from .exceptions import * +from .objects import File, Gist, Repository, User, bytes_to_b64 +from .urls import * __all__: Tuple[str, ...] = ( 'Paginator', @@ -73,9 +67,10 @@ APIType: TypeAlias = Union[User, Gist, Repository] async def make_session(*, headers: Dict[str, str], authorization: Union[aiohttp.BasicAuth, None]) -> aiohttp.ClientSession: """This makes the ClientSession, attaching the trace config and ensuring a UA header is present.""" if not headers.get('User-Agent'): - headers[ - 'User-Agent' - ] = f'Github-API-Wrapper (https://github.com/VarMonke/Github-Api-Wrapper) @ {__version__} Python {platform.python_version()} aiohttp {aiohttp.__version__}' + headers['User-Agent'] = ( + f'Github-API-Wrapper (https://github.com/VarMonke/Github-Api-Wrapper) @ {__version__} Python' + f' {platform.python_version()} aiohttp {aiohttp.__version__}' + ) session = aiohttp.ClientSession(auth=authorization, headers=headers, trace_configs=[trace_config]) session._rates = Rates('', '', '', '', '') @@ -140,9 +135,10 @@ class Paginator: class http: def __init__(self, headers: Dict[str, Union[str, int]], auth: Union[aiohttp.BasicAuth, None]) -> None: if not headers.get('User-Agent'): - headers[ - 'User-Agent' - ] = f'Github-API-Wrapper (https://github.com/VarMonke/Github-Api-Wrapper) @ {__version__} Python/{platform.python_version()} aiohttp/{aiohttp.__version__}' + headers['User-Agent'] = ( + 'Github-API-Wrapper (https://github.com/VarMonke/Github-Api-Wrapper) @' + f' {__version__} Python/{platform.python_version()} aiohttp/{aiohttp.__version__}' + ) self._rates = Rates('', '', '', '', '') self.headers = headers diff --git a/github/objects.py b/github/objects.py index a70f71d..8f0978e 100644 --- a/github/objects.py +++ b/github/objects.py @@ -1,18 +1,15 @@ # == objects.py ==# from __future__ import annotations + from base64 import b64encode -import json - -from typing import TYPE_CHECKING, Any, Literal, Optional, Tuple, Union, Dict, List - -import aiohttp +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union if TYPE_CHECKING: from .http import http -from datetime import datetime import io import os +from datetime import datetime __all__: Tuple[str, ...] = ( 'APIObject', @@ -201,7 +198,7 @@ class Repository(APIObject): 'id', 'name', 'owner', - 'size' 'created_at', + 'sizecreated_at', 'url', 'html_url', 'archived', @@ -346,7 +343,10 @@ class Issue(APIObject): continue def __repr__(self) -> str: - return f'<{self.__class__.__name__} id: {self.id}, title: {self.title}, user: {self.user}, created_at: {self.created_at}, state: {self.state}>' + return ( + f'<{self.__class__.__name__} id: {self.id}, title: {self.title}, user: {self.user}, created_at:' + f' {self.created_at}, state: {self.state}>' + ) @property def updated_at(self) -> Optional[datetime]: @@ -518,7 +518,10 @@ class Organization(APIObject): continue def __repr__(self): - return f'<{self.__class__.__name__} login: {self.login!r}, id: {self.id}, is_verified: {self.is_verified}, public_repos: {self.public_repos}, public_gists: {self.public_gists}, created_at: {self.created_at}>' + return ( + f'<{self.__class__.__name__} login: {self.login!r}, id: {self.id}, is_verified: {self.is_verified},' + f' public_repos: {self.public_repos}, public_gists: {self.public_gists}, created_at: {self.created_at}>' + ) @property def description(self): diff --git a/github/urls.py b/github/urls.py index 7182c58..dc6c639 100644 --- a/github/urls.py +++ b/github/urls.py @@ -4,40 +4,40 @@ BASE_URL = 'https://api.github.com' # == user urls ==# -USERS_URL = BASE_URL + '/users/{0}' +USERS_URL = f"{BASE_URL}/users/{{0}}" USER_HTML_URL = 'https://github.com/users/{0}' -SELF_URL = BASE_URL + '/user' +SELF_URL = f"{BASE_URL}/user" -USER_REPOS_URL = USERS_URL + '/repos' +USER_REPOS_URL = f"{USERS_URL}/repos" -USER_ORGS_URL = USERS_URL + '/orgs' +USER_ORGS_URL = f"{USERS_URL}/orgs" -USER_GISTS_URL = USERS_URL + '/gists' +USER_GISTS_URL = f"{USERS_URL}/gists" -USER_FOLLOWERS_URL = USERS_URL + '/followers' +USER_FOLLOWERS_URL = f"{USERS_URL}/followers" -USER_FOLLOWING_URL = USERS_URL + '/following' +USER_FOLLOWING_URL = f"{USERS_URL}/following" # == repo urls ==# -CREATE_REPO_URL = BASE_URL + '/user/repos' # _auth repo create +CREATE_REPO_URL = f"{BASE_URL}/user/repos" # _auth repo create -REPOS_URL = BASE_URL + '/repos/{0}' # repos of a user +REPOS_URL = f"{BASE_URL}/repos/{{0}}" # repos of a user -REPO_URL = BASE_URL + '/repos/{0}/{1}' # a specific repo +REPO_URL = f"{BASE_URL}/repos/{{0}}/{{1}}" # a specific repo -ADD_FILE_URL = BASE_URL + '/repos/{}/{}/contents/{}' +ADD_FILE_URL = f"{BASE_URL}/repos/{{}}/{{}}/contents/{{}}" -ADD_FILE_BRANCH = BASE_URL + '' +ADD_FILE_BRANCH = f"{BASE_URL}" -REPO_ISSUE_URL = REPO_URL + '/issues/{2}' # a specific issue +REPO_ISSUE_URL = f"{REPO_URL}/issues/{{2}}" # a specific issue # == gist urls ==# -GIST_URL = BASE_URL + '/gists/{0}' # specific gist +GIST_URL = f"{BASE_URL}/gists/{{0}}" # specific gist -CREATE_GIST_URL = BASE_URL + '/gists' # create a gist +CREATE_GIST_URL = f"{BASE_URL}/gists" # create a gist # == org urls ==# -ORG_URL = BASE_URL + '/orgs/{0}' +ORG_URL = f"{BASE_URL}/orgs/{{0}}" diff --git a/setup.py b/setup.py index 73e2610..4314b45 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ import re from pathlib import Path + from setuptools import setup ROOT_DIR = Path(__file__).parent From 573617afa8ddfb7baf9927f749222d490993ac57 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:07:04 +0300 Subject: [PATCH 14/14] Make setup.py simpler... again. --- setup.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 73e2610..3f13be4 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,6 @@ import re from pathlib import Path from setuptools import setup -ROOT_DIR = Path(__file__).parent - packages = [ 'github', ] @@ -21,11 +19,11 @@ setup( name='github', author='VarMonke & sudosnok', url='https://github.com/VarMonke/Github-Api-Wrapper', - version=re.search(r'\d[.]\d[.]\d', (ROOT_DIR / "github" / "__init__.py").read_text())[0], + version=re.search(r'\d[.]\d[.]\d', (Path('github') / '__init__.py').read_text())[0], packages=packages, license='MIT', description='An asynchronous python wrapper around the GitHub API', - long_description=(ROOT_DIR / "README.rst").read_text(), - install_requires=(ROOT_DIR / "requirements.txt").read_text().splitlines(), + long_description=Path('README.rst').read_text(), + install_requires=Path('requirements.txt').read_text().splitlines(), python_requires='>=3.8.0', )