Skip to content

Commit

Permalink
Bump Typeguard version from 2.x to 4.3.0 (#574)
Browse files Browse the repository at this point in the history
The latest Typeguard version (before 3.x) recompiles the target function with added instrumentation, so this result is not unexpected.

* Removed support for class methods in JSON-RPC methods: Issue #319
* Added support for from __future__ import annotations
  • Loading branch information
nycholas authored Oct 5, 2024
1 parent 78a61e0 commit de93cae
Show file tree
Hide file tree
Showing 48 changed files with 685 additions and 657 deletions.
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ updates:
directory: /requirements
schedule:
interval: daily
ignore:
- dependency-name: "typeguard"
groups:
python-requirements:
patterns:
Expand Down
15 changes: 2 additions & 13 deletions examples/async/async_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,12 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
import asyncio
from typing import NoReturn, Optional
import asyncio

from flask import Flask

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC

app = Flask('wba')
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)
Expand Down
14 changes: 2 additions & 12 deletions examples/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,15 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys

import typing as t

from flask import Flask, request

if t.TYPE_CHECKING:
from flask.typing import ResponseReturnValue

try:
from flask_jsonrpc import JSONRPC, JSONRPCView
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC, JSONRPCView
from flask_jsonrpc import JSONRPC, JSONRPCView


class UnauthorizedError(Exception):
Expand Down
14 changes: 2 additions & 12 deletions examples/cerberus_params_validator/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,13 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
from typing import Any, Dict

from flask import Flask
from cerberus import Validator

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)
from cerberus import Validator

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC
from flask_jsonrpc.exceptions import InvalidParamsError

app = Flask('cerberus')
Expand Down
16 changes: 3 additions & 13 deletions examples/cerberus_params_validator/example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,14 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
from typing import Any, Dict, Optional, Self
from typing import Any, Dict, Self, Optional
from dataclasses import dataclass

from flask import Flask
from cerberus import Validator

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)
from cerberus import Validator

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC
from flask_jsonrpc.exceptions import InvalidParamsError

app = Flask('cerberus')
Expand Down
16 changes: 3 additions & 13 deletions examples/cerberus_params_validator/example3.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,13 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
from typing import Any, Callable, Dict, Optional, Self
from typing import Any, Dict, Self, Callable, Optional

from flask import Flask
from cerberus import Validator

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)
from cerberus import Validator

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC
from flask_jsonrpc.exceptions import InvalidParamsError

app = Flask('cerberus')
Expand Down
13 changes: 1 addition & 12 deletions examples/decorator/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,11 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
from typing import Any, Callable

from flask import Flask, request

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC

app = Flask('decorator')
jsonrpc = JSONRPC(app, '/api')
Expand Down
14 changes: 1 addition & 13 deletions examples/gevent/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,11 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys

from flask import Flask

from gevent.pywsgi import WSGIServer

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC

app = Flask('gevent')
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)
Expand Down
16 changes: 2 additions & 14 deletions examples/hrx/hrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,12 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys

from flask import Flask, render_template

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC

from api.hello import hello # noqa: E402 pylint: disable=C0413,E0611

from flask_jsonrpc import JSONRPC

app = Flask('hrx')
app.config.from_object('hrx')
jsonrpc = JSONRPC(app, '/api')
Expand Down
13 changes: 1 addition & 12 deletions examples/minimal/minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,12 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
import typing as t
from numbers import Real

from flask import Flask

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC

app = Flask('minimal')
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)
Expand Down
15 changes: 2 additions & 13 deletions examples/modular/modular.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,15 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import typing as t
import os
import sys

from flask import Flask

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC

from api.user import user # noqa: E402 pylint: disable=C0413,E0611
from api.article import article # noqa: E402 pylint: disable=C0413,E0611

from flask_jsonrpc import JSONRPC

app = Flask('modular')
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)
jsonrpc.register_blueprint(app, user, url_prefix='/user', enable_web_browsable_api=True)
Expand Down
14 changes: 1 addition & 13 deletions examples/multiplesite/multiplesite.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,9 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys

from flask import Flask

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC

app = Flask('multiplesite')
jsonrpc_v1 = JSONRPC(app, '/api/v1', enable_web_browsable_api=True)
Expand Down
19 changes: 3 additions & 16 deletions examples/openrpc/petstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,14 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
import typing as t
import random
import typing as t
from dataclasses import dataclass

from flask import Flask

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC

from flask_jsonrpc.contrib.openrpc import OpenRPC
from flask_jsonrpc.contrib.openrpc import typing as st
from flask_jsonrpc import JSONRPC
from flask_jsonrpc.contrib.openrpc import OpenRPC, typing as st

app = Flask('openrpc')
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)
Expand Down
19 changes: 3 additions & 16 deletions examples/pydantic/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,15 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
import typing as t
import random
import typing as t

from flask import Flask

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC

from pydantic import BaseModel

from flask_jsonrpc.contrib.openrpc import OpenRPC
from flask_jsonrpc.contrib.openrpc import typing as st
from flask_jsonrpc import JSONRPC
from flask_jsonrpc.contrib.openrpc import OpenRPC, typing as st

app = Flask('openrpc')
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)
Expand Down
15 changes: 2 additions & 13 deletions examples/register_view_func/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,13 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# isort:skip_file
import os
import sys
import typing as t
from typing import Any, Dict, List, Union, NoReturn, Optional
from numbers import Real
import typing as t

from flask import Flask

try:
from flask_jsonrpc import JSONRPC
except ModuleNotFoundError:
project_dir, project_module_name = os.path.split(os.path.dirname(os.path.realpath(__file__)))
flask_jsonrpc_project_dir = os.path.join(project_dir, os.pardir, 'src')
if os.path.exists(flask_jsonrpc_project_dir) and flask_jsonrpc_project_dir not in sys.path:
sys.path.append(flask_jsonrpc_project_dir)

from flask_jsonrpc import JSONRPC
from flask_jsonrpc import JSONRPC


class MyApp:
Expand Down
Loading

0 comments on commit de93cae

Please sign in to comment.