Skip to content

Commit eaf18f9

Browse files
authored
🔧 add test config (#82)
1 parent 469afbb commit eaf18f9

File tree

9 files changed

+110
-7
lines changed

9 files changed

+110
-7
lines changed

codegen/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ def build_latest_version(
162162
):
163163
logger.info("Start generating latest version...")
164164

165+
# build pkg
166+
logger.info("Building latest __init__.py...")
167+
init_template = env.get_template("__init__.py.jinja")
168+
init_path = dir / "__init__.py"
169+
init_path.write_text(init_template.render())
170+
165171
# build models
166172
logger.info("Building latest models...")
167173
latest_template = env.get_template("latest/models.py.jinja")
@@ -296,6 +302,11 @@ def build():
296302
version_path = config.output_dir / version_module
297303
version_path.mkdir(parents=True, exist_ok=True)
298304

305+
# generate __init__.py
306+
init_template = env.get_template("__init__.py.jinja")
307+
init_path = version_path / "__init__.py"
308+
init_path.write_text(init_template.render())
309+
299310
# generate models
300311
model_path = version_path / "models"
301312
model_path.mkdir(parents=True, exist_ok=True)

codegen/templates/__init__.py.jinja

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% from "header.jinja" import header %}
2+
3+
"""{{ header() }}"""

githubkit/compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __get_validators__(cls) -> Generator[Callable[..., Any], None, None]:
2929
CVC = TypeVar("CVC", bound=CustomValidationClass)
3030

3131

32-
if PYDANTIC_V2:
32+
if PYDANTIC_V2: # pragma: pydantic-v2
3333
from pydantic_core import CoreSchema, core_schema
3434
from pydantic import (
3535
BaseModel,
@@ -80,7 +80,7 @@ def custom_validation(class_: Type["CVC"]) -> Type["CVC"]:
8080
)
8181
return class_
8282

83-
else:
83+
else: # pragma: pydantic-v1
8484
from pydantic import Extra, BaseModel, parse_obj_as, parse_raw_as, root_validator
8585

8686
class GitHubModel(BaseModel):

githubkit/typing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
]
4646
RequestFiles: TypeAlias = Union[Dict[str, FileTypes], List[Tuple[str, FileTypes]]]
4747

48-
if PYDANTIC_V2:
48+
if PYDANTIC_V2: # pragma: pydantic-v2
4949
from pydantic import AfterValidator
5050
from pydantic_core import PydanticCustomError
5151

@@ -59,7 +59,7 @@ def _validate_unique_list(value: List[H]) -> List[H]:
5959
AfterValidator(_validate_unique_list),
6060
Field(json_schema_extra={"uniqueItems": True}),
6161
]
62-
else:
62+
else: # pragma: pydantic-v1
6363
UniqueList: TypeAlias = Annotated[List[H], Field(unique_items=True)] # type: ignore
6464

6565
# if the property is not required, we allow it to have the value null.

githubkit/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from .compat import PYDANTIC_V2, custom_validation, type_validate_python
99

10-
if PYDANTIC_V2:
10+
if PYDANTIC_V2: # pragma: pydantic-v2
1111
from pydantic_core import core_schema
1212
from pydantic import GetCoreSchemaHandler
1313

@@ -94,7 +94,7 @@ def __init__(self, type_: Type[T], discriminator: str, tag: str) -> None:
9494
def _validate(self, value: Any) -> T:
9595
return type_validate_python(self.type_, value)
9696

97-
if PYDANTIC_V2:
97+
if PYDANTIC_V2: # pragma: pydantic-v2
9898

9999
def __get_pydantic_core_schema__(
100100
self, _source_type: Any, _handler: "GetCoreSchemaHandler"

githubkit/versions/latest/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""DO NOT EDIT THIS FILE!
2+
3+
This file is automatically @generated by githubkit using the follow command:
4+
5+
python -m codegen && isort . && black .
6+
7+
See https://github.com/github/rest-api-description for more information.
8+
"""
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""DO NOT EDIT THIS FILE!
2+
3+
This file is automatically @generated by githubkit using the follow command:
4+
5+
python -m codegen && isort . && black .
6+
7+
See https://github.com/github/rest-api-description for more information.
8+
"""

poetry.lock

Lines changed: 51 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ anyio = "*"
3636
pytest = "^7.4.3"
3737
pytest-cov = "^4.1.0"
3838
pytest-xdist = "^3.5.0"
39+
coverage-conditional-plugin = "^0.9.0"
3940

4041
[tool.poetry.extras]
4142
jwt = ["PyJWT"]
@@ -48,6 +49,28 @@ all = ["PyJWT", "anyio"]
4849
addopts = "--cov=githubkit --cov-append --cov-report=term-missing"
4950
filterwarnings = ["error", "ignore::DeprecationWarning"]
5051

52+
[tool.coverage.run]
53+
plugins = ["coverage_conditional_plugin"]
54+
55+
[tool.coverage.report]
56+
exclude_lines = [
57+
"pragma: no cover",
58+
"def __repr__",
59+
"def __str__",
60+
"@(typing\\.)?overload",
61+
"if (typing\\.)?TYPE_CHECKING( is True)?:",
62+
"@(abc\\.)?abstractmethod",
63+
"raise NotImplementedError",
64+
"warnings\\.warn",
65+
"^\\.\\.\\.$",
66+
"pass",
67+
"if __name__ == .__main__.:",
68+
]
69+
70+
[tool.coverage.coverage_conditional_plugin.rules]
71+
pydantic-v2 = "package_version('pydantic') < (2,)"
72+
pydantic-v1 = "package_version('pydantic') >= (2,)"
73+
5174
[tool.black]
5275
line-length = 88
5376
target-version = ["py38", "py39", "py310", "py311"]

0 commit comments

Comments
 (0)