Explorar o código

feat: fix pycodestyle

Joao Andre hai 1 ano
pai
achega
1dc18d2230

+ 1 - 1
src/taipy/_run.py

@@ -57,7 +57,7 @@ def _run(*services: _AppType, **kwargs) -> t.Optional[Flask]:
         return None
         return None
 
 
     if gui and rest:
     if gui and rest:
-        gui._set_flask(rest._app)
+        gui._set_flask(rest._app)  # type: ignore
         return gui.run(**kwargs)
         return gui.run(**kwargs)
     else:
     else:
         app = rest or gui
         app = rest or gui

+ 2 - 6
src/taipy/rest/Pipfile

@@ -4,21 +4,17 @@ verify_ssl = true
 name = "pypi"
 name = "pypi"
 
 
 [packages]
 [packages]
-apispec = {extras = ["yaml"], version = "==5.0"}
+apispec = {extras = ["yaml"], version = "==6.3"}
 apispec-webframeworks = "==0.5.2"
 apispec-webframeworks = "==0.5.2"
-Flask-Migrate = ">=3.0"
 Flask-RESTful = ">=0.3.9"
 Flask-RESTful = ">=0.3.9"
-flask-marshmallow = ">=0.14"
-markupsafe = "==2.1.1"
-passlib = "==1.7.4"
 taipy-core = {ref = "develop", git = "https://github.com/avaiga/taipy-core.git"}
 taipy-core = {ref = "develop", git = "https://github.com/avaiga/taipy-core.git"}
 flask = "==3.0.0"
 flask = "==3.0.0"
+marshmallow = "==3.20.1"
 
 
 [dev-packages]
 [dev-packages]
 tox = ">=3.24.5"
 tox = ">=3.24.5"
 black = "*"
 black = "*"
 pytest = "*"
 pytest = "*"
-pytest-factoryboy = "*"
 pre-commit = "*"
 pre-commit = "*"
 pytest-mock = "*"
 pytest-mock = "*"
 pytest-cov = "*"
 pytest-cov = "*"

+ 4 - 4
src/taipy/rest/api/resources/cycle.py

@@ -77,7 +77,7 @@ class CycleResource(Resource):
                 This Python example requires the 'requests' package to be installed (`pip install requests`).
                 This Python example requires the 'requests' package to be installed (`pip install requests`).
                 ```python
                 ```python
                 import requests
                 import requests
-                    response = requests.get("http://localhost:5000/api/v1/cycles/CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a")
+                    response = requests.get("http://localhost:5000/api/v1/cycles/CYCLE_223894_e019-b50b-4b9f-ac09-527a")
                     print(response)
                     print(response)
                     print(response.json())
                     print(response.json())
                 ```
                 ```
@@ -156,9 +156,9 @@ class CycleResource(Resource):
                 This Python example requires the 'requests' package to be installed (`pip install requests`).
                 This Python example requires the 'requests' package to be installed (`pip install requests`).
                 ```python
                 ```python
                 import requests
                 import requests
-                    response = requests.delete("http://localhost:5000/api/v1/cycles/CYCLE_797384_ef210412-af91-4f41-b6e8-74d1648edcba")
-                    print(response)
-                    print(response.json())
+                response = requests.delete("http://localhost:5000/api/v1/cycles/CYCLE_794_ef21-af91-4f41-b6e8-7648eda")
+                print(response)
+                print(response.json())
                 ```
                 ```
                 `CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a` is the value of the  *cycle_id* parameter. It
                 `CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a` is the value of the  *cycle_id* parameter. It
                 represents the identifier of the Cycle we want to delete.
                 represents the identifier of the Cycle we want to delete.

+ 9 - 5
src/taipy/rest/api/resources/datanode.py

@@ -32,10 +32,10 @@ from ..schemas import (
     GenericDataNodeConfigSchema,
     GenericDataNodeConfigSchema,
     InMemoryDataNodeConfigSchema,
     InMemoryDataNodeConfigSchema,
     JSONDataNodeConfigSchema,
     JSONDataNodeConfigSchema,
+    MongoCollectionDataNodeConfigSchema,
     PickleDataNodeConfigSchema,
     PickleDataNodeConfigSchema,
-    SQLTableDataNodeConfigSchema,
     SQLDataNodeConfigSchema,
     SQLDataNodeConfigSchema,
-    MongoCollectionDataNodeConfigSchema,
+    SQLTableDataNodeConfigSchema,
 )
 )
 
 
 ds_schema_map = {
 ds_schema_map = {
@@ -612,15 +612,19 @@ class DataNodeWriter(Resource):
         - api
         - api
       summary: Write into a data node.
       summary: Write into a data node.
       description: |
       description: |
-        Write data from request body into a data node by *datanode_id*. If the data node does not exist, a 404 error is returned.
+        Write data from request body into a data node by *datanode_id*. If the data node does not exist, a 404 error is
+        returned.
 
 
         !!! Note
         !!! Note
-          When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint requires `TAIPY_EDITOR` role.
+          When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint
+          requires `TAIPY_EDITOR` role.
 
 
         Code example:
         Code example:
 
 
         ```shell
         ```shell
-          curl -X PUT -d '[{"path": "/abc", "type": 1}, {"path": "/def", "type": 2}]' -H 'Content-Type: application/json'  http://localhost:5000/api/v1/datanodes/DATANODE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9/write
+          curl -X PUT -d '[{"path": "/abc", "type": 1}, {"path": "/def", "type": 2}]' \\
+          -H 'Content-Type: application/json' \\
+           http://localhost:5000/api/v1/datanodes/DATANODE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9/write
         ```
         ```
 
 
       parameters:
       parameters:

+ 1 - 1
src/taipy/rest/api/resources/scenario.py

@@ -460,7 +460,7 @@ class ScenarioExecutor(Resource):
 
 
             === "Curl"
             === "Curl"
                 ```shell
                 ```shell
-                    curl -X POST http://localhost:5000/api/v1/scenarios/submit/SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c
+                    curl -X POST http://localhost:5000/api/v1/scenarios/submit/SCENARIO_658d-5834-4d73-84e4-a6343df5e08c
                 ```
                 ```
                 In this example the REST API is served on port 5000 on localhost. We are using curl command line
                 In this example the REST API is served on port 5000 on localhost. We are using curl command line
                 client.
                 client.

+ 5 - 3
src/taipy/rest/api/resources/sequence.py

@@ -163,7 +163,8 @@ class SequenceList(Resource):
         - api
         - api
       summary: Create a sequence.
       summary: Create a sequence.
       description: |
       description: |
-        Create a sequence from scenario_id, sequence_name and task_ids. If the scenario_id does not exist or sequence_name is not provided, a 404 error is returned.
+        Create a sequence from scenario_id, sequence_name and task_ids. If the scenario_id does not exist or
+        sequence_name is not provided, a 404 error is returned.
         !!! Note
         !!! Note
           When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint
           When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint
           requires _TAIPY_EDITOR_ role.
           requires _TAIPY_EDITOR_ role.
@@ -171,7 +172,8 @@ class SequenceList(Resource):
         Code example:
         Code example:
 
 
         ```shell
         ```shell
-          curl -X POST --data '{"scenario_id": "SCENARIO_scenario_id", "sequence_name": "sequence", "tasks": []}' http://localhost:5000/api/v1/sequences
+          curl -X POST --data '{"scenario_id": "SCENARIO_scenario_id", "sequence_name": "sequence", "tasks": []}' \\
+           http://localhost:5000/api/v1/sequences
         ```
         ```
 
 
       parameters:
       parameters:
@@ -256,7 +258,7 @@ class SequenceExecutor(Resource):
         Code example:
         Code example:
 
 
         ```shell
         ```shell
-          curl -X POST http://localhost:5000/api/v1/sequences/submit/SEQUENCE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9
+          curl -X POST http://localhost:5000/api/v1/sequences/submit/SEQUENCE_my_config_7575-4e09-4e00-958d-e352ee426cc9
         ```
         ```
 
 
       parameters:
       parameters:

+ 0 - 1
src/taipy/rest/api/schemas/task.py

@@ -13,7 +13,6 @@ from marshmallow import Schema, fields
 
 
 
 
 class TaskSchema(Schema):
 class TaskSchema(Schema):
-
     config_id = fields.String()
     config_id = fields.String()
     id = fields.String()
     id = fields.String()
     owner_id = fields.String()
     owner_id = fields.String()

+ 13 - 3
src/taipy/rest/commons/encoder.py

@@ -1,12 +1,22 @@
+# Copyright 2023 Avaiga Private Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations under the License.
+
 import json
 import json
-from typing import Any, Union
 from datetime import datetime
 from datetime import datetime
 from enum import Enum
 from enum import Enum
-
-
+from typing import Any, Union
 
 
 Json = Union[dict, list, str, int, float, bool, None]
 Json = Union[dict, list, str, int, float, bool, None]
 
 
+
 class _CustomEncoder(json.JSONEncoder):
 class _CustomEncoder(json.JSONEncoder):
     def default(self, o: Any) -> Json:
     def default(self, o: Any) -> Json:
         if isinstance(o, Enum):
         if isinstance(o, Enum):

+ 0 - 6
src/taipy/rest/extensions.py

@@ -14,13 +14,7 @@
 All extensions here are used as singletons and
 All extensions here are used as singletons and
 initialized in application factory
 initialized in application factory
 """
 """
-from flask_marshmallow import Marshmallow
-from flask_migrate import Migrate
-from passlib.context import CryptContext
 
 
 from .commons.apispec import APISpecExt
 from .commons.apispec import APISpecExt
 
 
-ma = Marshmallow()
-migrate = Migrate()
 apispec = APISpecExt()
 apispec = APISpecExt()
-pwd_context = CryptContext(schemes=["pbkdf2_sha256"], deprecated="auto")

+ 3 - 2
src/taipy/rest/rest.py

@@ -31,8 +31,9 @@ class Rest:
         However, editing these parameters is only recommended for advanced users. Indeed, the default behavior of the
         However, editing these parameters is only recommended for advanced users. Indeed, the default behavior of the
         REST server without any required configuration satisfies all the standard and basic needs.
         REST server without any required configuration satisfies all the standard and basic needs.
         """
         """
-        self._app = _create_app(Config.global_config.testing or False, Config.global_config.env,
-                                Config.global_config.secret_key)
+        self._app = _create_app(
+            Config.global_config.testing or False, Config.global_config.env, Config.global_config.secret_key
+        )
 
 
     def run(self, **kwargs):
     def run(self, **kwargs):
         """
         """

+ 2 - 4
src/taipy/rest/setup.py

@@ -49,11 +49,9 @@ setup(
     install_requires=[
     install_requires=[
         "flask>=3.0.0,<3.1",
         "flask>=3.0.0,<3.1",
         "flask-restful>=0.3.9,<0.4",
         "flask-restful>=0.3.9,<0.4",
-        "flask-migrate>=3.1,<4.0",
-        "flask-marshmallow>=0.14,<0.15",
-        "marshmallow-sqlalchemy>=0.25,<0.29",
         "passlib>=1.7.4,<1.8",
         "passlib>=1.7.4,<1.8",
-        "apispec[yaml]>=5.1,<6.0",
+        "marshmallow>=3.20.1,<3.30",
+        "apispec[yaml]>=6.3,<7.0",
         "apispec-webframeworks>=0.5.2,<0.6",
         "apispec-webframeworks>=0.5.2,<0.6",
         "taipy-core@git+https://git@github.com/Avaiga/taipy-core.git@develop",
         "taipy-core@git+https://git@github.com/Avaiga/taipy-core.git@develop",
     ],
     ],