diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 000000000..f59993847 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,17 @@ +name: Ruff Lint + +on: + push: + branches: + - master + pull_request: + +jobs: + ruff: + name: Ruff Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Run Ruff Lint + uses: chartboost/ruff-action@v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f071a4c20..7b0e48a59 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,13 @@ ci: autoupdate_schedule: monthly autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks" repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.286 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + stages: [commit] + - repo: https://github.com/pycqa/isort rev: 5.12.0 hooks: diff --git a/codegen/__init__.py b/codegen/__init__.py index b00a8d719..f847cfd83 100644 --- a/codegen/__init__.py +++ b/codegen/__init__.py @@ -141,7 +141,8 @@ def build(): parsed_data = parse_openapi_spec(source, versioned_rest, config) logger.info( f"Successfully parsed OpenAPI spec {versioned_rest.version}: " - f"{len(parsed_data.schemas)} schemas, {len(parsed_data.endpoints)} endpoints" + f"{len(parsed_data.schemas)} schemas, " + f"{len(parsed_data.endpoints)} endpoints" ) build_rest_api(parsed_data, versioned_rest) diff --git a/codegen/config.py b/codegen/config.py index c41812ef9..0c062033c 100644 --- a/codegen/config.py +++ b/codegen/config.py @@ -1,6 +1,5 @@ from typing import Any, Dict, List -import openapi_pydantic as oas from pydantic import Field, BaseModel diff --git a/codegen/parser/data.py b/codegen/parser/data.py index a0495037b..7f8a2d2da 100644 --- a/codegen/parser/data.py +++ b/codegen/parser/data.py @@ -3,8 +3,6 @@ from functools import cached_property from typing import Dict, List, Union, Optional -from pydantic import BaseModel - from .endpoints import EndpointData from .schemas import SchemaData, ModelSchema diff --git a/codegen/parser/schemas/enum_schema.py b/codegen/parser/schemas/enum_schema.py index be2a577ad..b49d591fb 100644 --- a/codegen/parser/schemas/enum_schema.py +++ b/codegen/parser/schemas/enum_schema.py @@ -1,7 +1,5 @@ from typing import Union, Optional -import openapi_pydantic as oas - from ...source import Source from ..utils import schema_from_source from .schema import EnumSchema, NoneSchema, UnionSchema diff --git a/codegen/parser/schemas/float_schema.py b/codegen/parser/schemas/float_schema.py index 15a474cd7..3bd7a95e2 100644 --- a/codegen/parser/schemas/float_schema.py +++ b/codegen/parser/schemas/float_schema.py @@ -1,7 +1,5 @@ from typing import Optional -import openapi_pydantic as oas - from ...source import Source from .schema import FloatSchema from ..utils import schema_from_source diff --git a/codegen/parser/schemas/int_schema.py b/codegen/parser/schemas/int_schema.py index 86df6f384..9fffb07d6 100644 --- a/codegen/parser/schemas/int_schema.py +++ b/codegen/parser/schemas/int_schema.py @@ -1,7 +1,5 @@ from typing import Optional -import openapi_pydantic as oas - from ...source import Source from .schema import IntSchema from ..utils import schema_from_source diff --git a/codegen/parser/schemas/list_schema.py b/codegen/parser/schemas/list_schema.py index a71be1600..be18ccafb 100644 --- a/codegen/parser/schemas/list_schema.py +++ b/codegen/parser/schemas/list_schema.py @@ -1,7 +1,5 @@ from typing import Optional -import openapi_pydantic as oas - from . import parse_schema from ...source import Source from .schema import ListSchema diff --git a/codegen/parser/schemas/model_schema.py b/codegen/parser/schemas/model_schema.py index ddf37d659..687343a62 100644 --- a/codegen/parser/schemas/model_schema.py +++ b/codegen/parser/schemas/model_schema.py @@ -239,7 +239,8 @@ def _add_if_no_conflict(prop: Property): model = model.schemas[assertion.index(True)] if not isinstance(model, ModelSchema): raise ValueError( - f"Invalid schema {model!r} in allOf: {prop_source.uri} from {source.uri}" + f"Invalid schema {model!r} in allOf: " + f"{prop_source.uri} from {source.uri}" ) for prop in model.properties: _add_if_no_conflict(prop) diff --git a/codegen/parser/schemas/schema.py b/codegen/parser/schemas/schema.py index 17ac042ba..9261a0b8a 100644 --- a/codegen/parser/schemas/schema.py +++ b/codegen/parser/schemas/schema.py @@ -351,7 +351,8 @@ def get_type_string(self) -> str: def get_param_type_string(self) -> str: if len(self.schemas) == 1: return self.schemas[0].get_param_type_string() - return f"Union[{', '.join(schema.get_param_type_string() for schema in self.schemas)}]" + types = ", ".join(schema.get_param_type_string() for schema in self.schemas) + return f"Union[{types}]" def get_model_imports(self) -> Set[str]: imports = super().get_model_imports() diff --git a/codegen/parser/schemas/string_schema.py b/codegen/parser/schemas/string_schema.py index 8a3d02386..62cad7e98 100644 --- a/codegen/parser/schemas/string_schema.py +++ b/codegen/parser/schemas/string_schema.py @@ -1,7 +1,5 @@ from typing import Union, Optional -import openapi_pydantic as oas - from ...source import Source from ..utils import schema_from_source from .schema import DateSchema, FileSchema, StringSchema, DateTimeSchema diff --git a/codegen/parser/utils.py b/codegen/parser/utils.py index 76b3b1b3d..2bc4120ef 100644 --- a/codegen/parser/utils.py +++ b/codegen/parser/utils.py @@ -36,7 +36,8 @@ def split_words(value: str) -> List[str]: def fix_reserved_words(value: str) -> str: """ - Using reserved Python words as identifiers in generated code causes problems, so this function renames them. + Using reserved Python words as identifiers in generated code causes problems, + so this function renames them. Args: value: The identifier to-be that should be renamed if it's a reserved word. @@ -56,7 +57,7 @@ def snake_case(value: str) -> str: def pascal_case(value: str) -> str: """Converts to PascalCase""" words = split_words(sanitize(value)) - return "".join((word if word.isupper() else word.capitalize() for word in words)) + return "".join(word if word.isupper() else word.capitalize() for word in words) def kebab_case(value: str) -> str: diff --git a/githubkit/auth/action.py b/githubkit/auth/action.py index c49e177da..833caf3d8 100644 --- a/githubkit/auth/action.py +++ b/githubkit/auth/action.py @@ -18,7 +18,8 @@ def auth_flow( token = os.environ.get("GITHUB_TOKEN", os.environ.get("INPUT_GITHUB_TOKEN")) if not token: raise AuthCredentialError( - "`GITHUB_TOKEN` is not provided. Use `env:` or `with:` to input a token." + "`GITHUB_TOKEN` is not provided. " + "Use `env:` or `with:` to input a token." ) request.headers["Authorization"] = f"token {token}" yield request diff --git a/githubkit/auth/app.py b/githubkit/auth/app.py index 3105e78a1..978ef594e 100644 --- a/githubkit/auth/app.py +++ b/githubkit/auth/app.py @@ -44,7 +44,10 @@ class AppAuth(httpx.Auth): cache: "BaseCache" = DEFAULT_CACHE JWT_CACHE_KEY = "githubkit:auth:app:jwt" - INSTALLATION_CACHE_KEY = "githubkit:auth:app:installation:{installation_id}:{permissions}:{repositories}:{repository_ids}" + INSTALLATION_CACHE_KEY = ( + "githubkit:auth:app:installation:" + "{installation_id}:{permissions}:{repositories}:{repository_ids}" + ) def _create_jwt(self) -> str: """Create a JWT authenticating as GitHub APP. diff --git a/githubkit/cache/base.py b/githubkit/cache/base.py index 49d2db471..32a39a0ff 100644 --- a/githubkit/cache/base.py +++ b/githubkit/cache/base.py @@ -1,6 +1,6 @@ import abc -from typing import Union, Optional -from datetime import datetime, timedelta +from typing import Optional +from datetime import timedelta class BaseCache(abc.ABC): diff --git a/githubkit/core.py b/githubkit/core.py index bc3d282fb..6d0552c5d 100644 --- a/githubkit/core.py +++ b/githubkit/core.py @@ -125,7 +125,9 @@ def __init__( timeout: Optional[Union[float, httpx.Timeout]] = None, ): auth = auth or UnauthAuthStrategy() # type: ignore - self.auth: A = TokenAuthStrategy(auth) if isinstance(auth, str) else auth # type: ignore + self.auth: A = ( # type: ignore + TokenAuthStrategy(auth) if isinstance(auth, str) else auth + ) self.config = config or get_config( base_url, accept_format, previews, user_agent, follow_redirects, timeout diff --git a/githubkit/github.py b/githubkit/github.py index d7ea4ba1c..62effc632 100644 --- a/githubkit/github.py +++ b/githubkit/github.py @@ -184,4 +184,6 @@ def paginate( *args: CP.args, **kwargs: CP.kwargs, ) -> Paginator[RT]: - return Paginator(request, page, per_page, map_func, *args, **kwargs) # type: ignore + return Paginator( + request, page, per_page, map_func, *args, **kwargs # type: ignore + ) diff --git a/githubkit/paginator.py b/githubkit/paginator.py index 6bde764e6..23c1171e4 100644 --- a/githubkit/paginator.py +++ b/githubkit/paginator.py @@ -1,4 +1,3 @@ -import inspect from typing_extensions import Self, ParamSpec from typing import ( List, diff --git a/poetry.lock b/poetry.lock index 2ad110de3..953a3f6e9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "anyio" @@ -156,24 +156,24 @@ pycparser = "*" [[package]] name = "cfgv" -version = "3.3.1" +version = "3.4.0" description = "Validate configuration and produce human readable error messages." optional = false -python-versions = ">=3.6.1" +python-versions = ">=3.8" files = [ - {file = "cfgv-3.3.1-py2.py3-none-any.whl", hash = "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426"}, - {file = "cfgv-3.3.1.tar.gz", hash = "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736"}, + {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, + {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, ] [[package]] name = "click" -version = "8.1.6" +version = "8.1.7" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.7" files = [ - {file = "click-8.1.6-py3-none-any.whl", hash = "sha256:fa244bb30b3b5ee2cae3da8f55c9e5e0c0e86093306301fb418eb9dc40fbded5"}, - {file = "click-8.1.6.tar.gz", hash = "sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd"}, + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, ] [package.dependencies] @@ -248,13 +248,13 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.1.2" +version = "1.1.3" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.1.2-py3-none-any.whl", hash = "sha256:e346e69d186172ca7cf029c8c1d16235aa0e04035e5750b4b95039e65204328f"}, - {file = "exceptiongroup-1.1.2.tar.gz", hash = "sha256:12c3e887d6485d16943a309616de20ae5582633e0a2eda17f4e10fd61c1e8af5"}, + {file = "exceptiongroup-1.1.3-py3-none-any.whl", hash = "sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3"}, + {file = "exceptiongroup-1.1.3.tar.gz", hash = "sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9"}, ] [package.extras] @@ -262,18 +262,21 @@ test = ["pytest (>=6)"] [[package]] name = "filelock" -version = "3.12.2" +version = "3.12.3" description = "A platform independent file lock." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "filelock-3.12.2-py3-none-any.whl", hash = "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec"}, - {file = "filelock-3.12.2.tar.gz", hash = "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81"}, + {file = "filelock-3.12.3-py3-none-any.whl", hash = "sha256:f067e40ccc40f2b48395a80fcbd4728262fab54e232e090a4063ab804179efeb"}, + {file = "filelock-3.12.3.tar.gz", hash = "sha256:0ecc1dd2ec4672a10c8550a8182f1bd0c0a5088470ecd5a125e45f49472fac3d"}, ] +[package.dependencies] +typing-extensions = {version = ">=4.7.1", markers = "python_version < \"3.11\""} + [package.extras] -docs = ["furo (>=2023.5.20)", "sphinx (>=7.0.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] +docs = ["furo (>=2023.7.26)", "sphinx (>=7.1.2)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3)", "diff-cover (>=7.7)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest-timeout (>=2.1)"] [[package]] name = "h11" @@ -332,13 +335,13 @@ socks = ["socksio (==1.*)"] [[package]] name = "identify" -version = "2.5.26" +version = "2.5.27" description = "File identification library for Python" optional = false python-versions = ">=3.8" files = [ - {file = "identify-2.5.26-py2.py3-none-any.whl", hash = "sha256:c22a8ead0d4ca11f1edd6c9418c3220669b3b7533ada0a0ffa6cc0ef85cf9b54"}, - {file = "identify-2.5.26.tar.gz", hash = "sha256:7243800bce2f58404ed41b7c002e53d4d22bcf3ae1b7900c2d7aefd95394bf7f"}, + {file = "identify-2.5.27-py2.py3-none-any.whl", hash = "sha256:fdb527b2dfe24602809b2201e033c2a113d7bdf716db3ca8e3243f735dcecaba"}, + {file = "identify-2.5.27.tar.gz", hash = "sha256:287b75b04a0e22d727bc9a41f0d4f3c1bcada97490fa6eabb5b28f0e9097e733"}, ] [package.extras] @@ -690,6 +693,7 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -697,8 +701,15 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -715,6 +726,7 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -722,25 +734,52 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, ] +[[package]] +name = "ruff" +version = "0.0.286" +description = "An extremely fast Python linter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.0.286-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:8e22cb557e7395893490e7f9cfea1073d19a5b1dd337f44fd81359b2767da4e9"}, + {file = "ruff-0.0.286-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:68ed8c99c883ae79a9133cb1a86d7130feee0397fdf5ba385abf2d53e178d3fa"}, + {file = "ruff-0.0.286-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8301f0bb4ec1a5b29cfaf15b83565136c47abefb771603241af9d6038f8981e8"}, + {file = "ruff-0.0.286-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:acc4598f810bbc465ce0ed84417ac687e392c993a84c7eaf3abf97638701c1ec"}, + {file = "ruff-0.0.286-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:88c8e358b445eb66d47164fa38541cfcc267847d1e7a92dd186dddb1a0a9a17f"}, + {file = "ruff-0.0.286-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:0433683d0c5dbcf6162a4beb2356e820a593243f1fa714072fec15e2e4f4c939"}, + {file = "ruff-0.0.286-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ddb61a0c4454cbe4623f4a07fef03c5ae921fe04fede8d15c6e36703c0a73b07"}, + {file = "ruff-0.0.286-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:47549c7c0be24c8ae9f2bce6f1c49fbafea83bca80142d118306f08ec7414041"}, + {file = "ruff-0.0.286-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:559aa793149ac23dc4310f94f2c83209eedb16908a0343663be19bec42233d25"}, + {file = "ruff-0.0.286-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:d73cfb1c3352e7aa0ce6fb2321f36fa1d4a2c48d2ceac694cb03611ddf0e4db6"}, + {file = "ruff-0.0.286-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:3dad93b1f973c6d1db4b6a5da8690c5625a3fa32bdf38e543a6936e634b83dc3"}, + {file = "ruff-0.0.286-py3-none-musllinux_1_2_i686.whl", hash = "sha256:26afc0851f4fc3738afcf30f5f8b8612a31ac3455cb76e611deea80f5c0bf3ce"}, + {file = "ruff-0.0.286-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:9b6b116d1c4000de1b9bf027131dbc3b8a70507788f794c6b09509d28952c512"}, + {file = "ruff-0.0.286-py3-none-win32.whl", hash = "sha256:556e965ac07c1e8c1c2d759ac512e526ecff62c00fde1a046acb088d3cbc1a6c"}, + {file = "ruff-0.0.286-py3-none-win_amd64.whl", hash = "sha256:5d295c758961376c84aaa92d16e643d110be32add7465e197bfdaec5a431a107"}, + {file = "ruff-0.0.286-py3-none-win_arm64.whl", hash = "sha256:1d6142d53ab7f164204b3133d053c4958d4d11ec3a39abf23a40b13b0784e3f0"}, + {file = "ruff-0.0.286.tar.gz", hash = "sha256:f1e9d169cce81a384a26ee5bb8c919fe9ae88255f39a1a69fd1ebab233a85ed2"}, +] + [[package]] name = "setuptools" -version = "68.0.0" +version = "68.1.2" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "setuptools-68.0.0-py3-none-any.whl", hash = "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f"}, - {file = "setuptools-68.0.0.tar.gz", hash = "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235"}, + {file = "setuptools-68.1.2-py3-none-any.whl", hash = "sha256:3d8083eed2d13afc9426f227b24fd1659489ec107c0e86cec2ffdde5c92e790b"}, + {file = "setuptools-68.1.2.tar.gz", hash = "sha256:3d4dfa6d95f1b101d695a6160a7626e15583af71a5f52176efa5d39a054d475d"}, ] [package.extras] -docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5,<=7.1.2)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] [[package]] @@ -778,13 +817,13 @@ files = [ [[package]] name = "virtualenv" -version = "20.24.2" +version = "20.24.3" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.24.2-py3-none-any.whl", hash = "sha256:43a3052be36080548bdee0b42919c88072037d50d56c28bd3f853cbe92b953ff"}, - {file = "virtualenv-20.24.2.tar.gz", hash = "sha256:fd8a78f46f6b99a67b7ec5cf73f92357891a7b3a40fd97637c27f854aae3b9e0"}, + {file = "virtualenv-20.24.3-py3-none-any.whl", hash = "sha256:95a6e9398b4967fbcb5fef2acec5efaf9aa4972049d9ae41f95e0972a683fd02"}, + {file = "virtualenv-20.24.3.tar.gz", hash = "sha256:e5c3b4ce817b0b328af041506a2a299418c98747c4b1e68cb7527e74ced23efc"}, ] [package.dependencies] @@ -817,4 +856,4 @@ jwt = ["PyJWT"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "40f4f57345ce8031c9cb4681685e70cb8a2bf103118428058fac03079d6aee5f" +content-hash = "84e9d52bc648ba92c443cb870146b0bea39e7afe6eb3b1b87c7bfd6717536e1c" diff --git a/pyproject.toml b/pyproject.toml index 5c46159a8..8878d0551 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,10 +17,11 @@ pydantic = "^1.9.1" httpx = ">=0.23.0, <1.0.0" typing-extensions = "^4.3.0" anyio = { version = "^3.6.1", optional = true } -PyJWT = { version = "^2.4.0", extras=["crypto"], optional = true } +PyJWT = { version = "^2.4.0", extras = ["crypto"], optional = true } [tool.poetry.group.dev.dependencies] tomli = "^2.0.1" +ruff = "^0.0.286" isort = "^5.10.1" black = "^23.1.0" Jinja2 = "^3.1.2" @@ -51,10 +52,27 @@ skip_gitignore = true force_sort_within_sections = true extra_standard_library = ["typing_extensions"] +[tool.ruff] +select = ["E", "W", "F", "UP", "C", "T", "PYI", "PT", "Q"] +ignore = ["E402", "C901", "UP037"] +extend-exclude = ["githubkit/rest/", "githubkit/webhooks/"] + +line-length = 88 +target-version = "py38" + [tool.pyright] reportPrivateImportUsage = false reportShadowedImports = false +pythonPlatform = "All" +executionEnvironments = [ + { root = "./codegen", pythonVersion = "3.10" }, + { root = "./", pythonVersion = "3.8", extraPaths = [ + "./", + ] }, +] + + [[tool.codegen.rest]] version = "2022-11-28" description_source = "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions-next/api.github.com/api.github.com.2022-11-28.json" @@ -87,50 +105,110 @@ output_dir = "githubkit/rest/" # https://github.com/github/rest-api-description/issues/1639 "/components/schemas/issue/properties/body_text" = { type = ["string", "null"] } "/components/schemas/issue/properties/body_html" = { type = ["string", "null"] } -"/components/schemas/timeline-reviewed-event/properties/body_text" = { type = ["string", "null"] } -"/components/schemas/timeline-reviewed-event/properties/body_html" = { type = ["string", "null"] } -"/components/schemas/release/properties/body_text" = { type = ["string", "null"] } -"/components/schemas/release/properties/body_html" = { type = ["string", "null"] } +"/components/schemas/timeline-reviewed-event/properties/body_text" = { type = [ + "string", + "null", +] } +"/components/schemas/timeline-reviewed-event/properties/body_html" = { type = [ + "string", + "null", +] } +"/components/schemas/release/properties/body_text" = { type = [ + "string", + "null", +] } +"/components/schemas/release/properties/body_html" = { type = [ + "string", + "null", +] } # https://github.com/github/rest-api-description/issues/1811 "/components/schemas/pull-request-simple/properties/head/properties/repo" = { anyOf = [ - { type = "null" }, - { "$ref" = "#/components/schemas/repository" } + { type = "null" }, + { "$ref" = "#/components/schemas/repository" }, ], "$ref" = "" } # https://github.com/github/rest-api-description/issues/1812 -"/components/schemas/pull-request-simple/properties/labels/items/properties/description" = { type = ["string", "null"] } +"/components/schemas/pull-request-simple/properties/labels/items/properties/description" = { type = [ + "string", + "null", +] } # https://github.com/github/rest-api-description/issues/621 -"/components/schemas/repository/properties/temp_clone_token" = { type = ["string", "null"] } -"/components/schemas/repository/properties/template_repository/properties/temp_clone_token" = { type = ["string", "null"] } -"/components/schemas/minimal-repository/properties/temp_clone_token" = { type = ["string", "null"] } -"/components/schemas/team-repository/properties/temp_clone_token" = { type = ["string", "null"] } -"/components/schemas/pull-request/properties/head/properties/repo/properties/temp_clone_token" = { type = ["string", "null"] } -"/components/schemas/pull-request/properties/base/properties/repo/properties/temp_clone_token" = { type = ["string", "null"] } -"/components/schemas/repo-search-result-item/properties/temp_clone_token" = { type = ["string", "null"] } +"/components/schemas/repository/properties/temp_clone_token" = { type = [ + "string", + "null", +] } +"/components/schemas/repository/properties/template_repository/properties/temp_clone_token" = { type = [ + "string", + "null", +] } +"/components/schemas/minimal-repository/properties/temp_clone_token" = { type = [ + "string", + "null", +] } +"/components/schemas/team-repository/properties/temp_clone_token" = { type = [ + "string", + "null", +] } +"/components/schemas/pull-request/properties/head/properties/repo/properties/temp_clone_token" = { type = [ + "string", + "null", +] } +"/components/schemas/pull-request/properties/base/properties/repo/properties/temp_clone_token" = { type = [ + "string", + "null", +] } +"/components/schemas/repo-search-result-item/properties/temp_clone_token" = { type = [ + "string", + "null", +] } # https://github.com/github/rest-api-description/issues/2491 -"/components/schemas/auto-merge/properties/commit_title" = { type = ["string", "null"] } -"/components/schemas/auto-merge/properties/commit_message" = { type = ["string", "null"] } +"/components/schemas/auto-merge/properties/commit_title" = { type = [ + "string", + "null", +] } +"/components/schemas/auto-merge/properties/commit_message" = { type = [ + "string", + "null", +] } # https://github.com/github/rest-api-description/issues/2496 "/paths/~1repos~1{owner}~1{repo}~1releases/post/requestBody/content/application~1json/schema/properties/make_latest" = { default = "true" } "/paths/~1repos~1{owner}~1{repo}~1releases~1{release_id}/patch/requestBody/content/application~1json/schema/properties/make_latest" = { default = "true" } # https://github.com/github/rest-api-description/issues/2507 -"/components/schemas/organization-full/properties/company" = { type = ["string", "null"] } -"/components/schemas/organization-full/properties/email" = { type = ["string", "null"] } -"/components/schemas/organization-full/properties/location" = { type = ["string", "null"] } -"/components/schemas/team-organization/properties/company" = { type = ["string", "null"] } -"/components/schemas/team-organization/properties/email" = { type = ["string", "null"] } -"/components/schemas/team-organization/properties/location" = { type = ["string", "null"] } +"/components/schemas/organization-full/properties/company" = { type = [ + "string", + "null", +] } +"/components/schemas/organization-full/properties/email" = { type = [ + "string", + "null", +] } +"/components/schemas/organization-full/properties/location" = { type = [ + "string", + "null", +] } +"/components/schemas/team-organization/properties/company" = { type = [ + "string", + "null", +] } +"/components/schemas/team-organization/properties/email" = { type = [ + "string", + "null", +] } +"/components/schemas/team-organization/properties/location" = { type = [ + "string", + "null", +] } # copilot-seat-details/assignee is not valid "/components/schemas/copilot-seat-details/properties/assignee" = { enum = "", oneOf = [ { "$ref" = "#/components/schemas/simple-user" }, { "$ref" = "#/components/schemas/team" }, - { "$ref" = "#/components/schemas/organization" } + { "$ref" = "#/components/schemas/organization" }, ] } [tool.codegen.webhook] @@ -144,12 +222,18 @@ types_output = "githubkit/webhooks/types.py" # https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation "/definitions/installation$created/properties/requester" = { anyOf = [ { type = "null" }, - { "$ref" = "#/definitions/user" } + { "$ref" = "#/definitions/user" }, ], "$ref" = {} } # https://github.com/github/rest-api-description/issues/2491 -"/definitions/auto-merge/properties/commit_title" = { type = ["string", "null"] } -"/definitions/auto-merge/properties/commit_message" = { type = ["string", "null"] } +"/definitions/auto-merge/properties/commit_title" = { type = [ + "string", + "null", +] } +"/definitions/auto-merge/properties/commit_message" = { type = [ + "string", + "null", +] } # [FIXED] https://github.com/octokit/webhooks/issues/806 # "/definitions/secret_scanning_alert$resolved/properties/alert/allOf/1/properties/resolution" = { enum = ["false_positive", "wont_fix", "revoked", "used_in_tests"] }