Skip to content

Commit

Permalink
chore: fix pydantic to <2 (0b01001001#318)
Browse files Browse the repository at this point in the history
Signed-off-by: Keming <kemingy94@gmail.com>
  • Loading branch information
kemingy authored Jul 1, 2023
1 parent 82ff248 commit cfa91b5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Code example:
@api.validate(
deprecated=True,
)
def depreated_endpoint():
def deprecated_endpoint():
...
```

Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "spectree"
version = "1.1.3"
version = "1.1.4"
dynamic = []
description = "generate OpenAPI document and validate request&response with Python annotations."
readme = "README.md"
Expand Down Expand Up @@ -34,9 +34,10 @@ dev = [
"mypy>=0.971",
"pre-commit",
"pytest~=7.1",
"syrupy>=4.0",
]
email = [
"pydantic[email]>=1.2",
"pydantic[email]>=1.2,<2",
]
falcon = [
"falcon>=3.0.0",
Expand All @@ -47,6 +48,10 @@ flask = [
starlette = [
"starlette[full]",
]
docs = [
"Sphinx",
"furo",
]

[project.urls]
Homepage = "https://github.com/0b01001001/spectree"
Expand All @@ -62,7 +67,7 @@ plugins = ["pydantic.mypy"]
follow_imports = "silent"
ignore_missing_imports = true
show_error_codes = true
warn_unused_ignores = true
warn_unused_ignores = false
warn_redundant_casts = true
no_implicit_reexport = true
disable_error_code = ["attr-defined"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"pydantic>=1.2",
],
extras_require={
"email": ["pydantic[email]>=1.2"],
"email": ["pydantic[email]>=1.2,<2"],
"flask": ["flask"],
"quart": ["quart"],
"falcon": ["falcon>=3.0.0"],
Expand Down
6 changes: 3 additions & 3 deletions spectree/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

class MultiDict(Protocol):
def get(self, key: str) -> Optional[str]:
...
pass

def getlist(self, key: str) -> List[str]:
...
pass

def __iter__(self) -> Iterator[str]:
...
pass


class FunctionDecorator(Protocol):
Expand Down
4 changes: 2 additions & 2 deletions spectree/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from .base import BasePlugin

__all__ = ["BasePlugin"]

Plugin = namedtuple("Plugin", ("name", "package", "class_name"))

PLUGINS = {
Expand All @@ -14,3 +12,5 @@
"falcon-asgi": Plugin(".falcon_plugin", __name__, "FalconAsgiPlugin"),
"starlette": Plugin(".starlette_plugin", __name__, "StarlettePlugin"),
}

__all__ = ["BasePlugin", "PLUGINS", "Plugin"]
6 changes: 4 additions & 2 deletions spectree/plugins/starlette_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ def parse_route(app, prefix=""):
if isinstance(func, partial):
try:
func = func.__wrapped__
except AttributeError:
pass
except AttributeError as err:
self.logger.warning(
"failed to get the wrapped func %s: %s", func, err
)

if inspect.isclass(func):
for method in METHODS:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_config_license():
assert config.license.url == "https://opensource.org/licenses/MIT"

with pytest.raises(ValidationError):
config = Configuration(license={"name": "MIT", "url": "url"})
Configuration(license={"name": "MIT", "url": "url"})


def test_config_contact():
Expand All @@ -37,7 +37,7 @@ def test_config_contact():
assert config.contact.email == "hello@github.com"

with pytest.raises(ValidationError):
config = Configuration(contact={"name": "John", "url": "url"})
Configuration(contact={"name": "John", "url": "url"})


@pytest.mark.skipif(EmailFieldType == str, reason="email-validator is not installled")
Expand Down
3 changes: 3 additions & 0 deletions tests/test_plugin_quart.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ async def list_json():
# INFO: ensures that spec is calculated and cached _after_ registering
# view functions for validations. This enables tests to access `api.spec`
# without app_context.
# TODO: this is commented out because it requires async context
# with app.app_context():
# api.spec
api.register(app)
Expand Down Expand Up @@ -262,6 +263,7 @@ async def oauth_two_ping():
return jsonify(msg="pong")


# TODO: this is commented out because it requires async context
# with app_secure.app_context():
# api_secure.spec

Expand Down Expand Up @@ -332,6 +334,7 @@ async def global_security_or():
return jsonify(msg="pong")


# TODO: this is commented out because it requires async context
# with app_global_secure.app_context():
# api_global_secure.spec

Expand Down

0 comments on commit cfa91b5

Please sign in to comment.