Skip to content

Commit dd6af0e

Browse files
committed
mypy
1 parent 8b8765c commit dd6af0e

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/opengeodeweb_back/geode_functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import opengeode as og # type: ignore
77
import werkzeug
88
import flask
9+
from typing import Any
910

1011
# Local application imports
1112
from .geode_objects import geode_objects_dict
@@ -54,7 +55,7 @@ def data_file_path(data_id: str, filename: str = "") -> str:
5455
return os.path.join(data_folder_path, data_id)
5556

5657

57-
def load_data(data_id: str) -> og.GeodeObject:
58+
def load_data(data_id: str) -> Any:
5859
data_entry = Data.get(data_id)
5960
if not data_entry:
6061
flask.abort(404, f"Data with id {data_id} not found")

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import flask
88
import opengeode
99
import werkzeug
10-
from typing import Any, Dict
1110

1211
# Local application imports
1312
from .. import geode_functions, utils_functions
@@ -291,8 +290,8 @@ def create_point():
291290
)
292291
def texture_coordinates():
293292
utils_functions.validate_request(flask.request, texture_coordinates_json)
294-
data = geode_functions.load_data(flask.request.json["id"])
295-
texture_coordinates_json: Dict[str, Any] = json.load(file)
293+
data = geode_functions.load_data(flask.request.json.get("id"))
294+
texture_coordinates = data.texture_manager().texture_names()
296295
return flask.make_response({"texture_coordinates": texture_coordinates}, 200)
297296

298297

@@ -309,8 +308,8 @@ def texture_coordinates():
309308
)
310309
def vertex_attribute_names():
311310
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
312-
data = geode_functions.load_data(flask.request.json["id"])
313-
vertex_attribute_names_json: Dict[str, Any] = json.load(file)
311+
data = geode_functions.load_data(flask.request.json("id"))
312+
vertex_attribute_names = data.vertex_attribute_manager().attribute_names()
314313
return flask.make_response(
315314
{
316315
"vertex_attribute_names": vertex_attribute_names,
@@ -332,8 +331,8 @@ def vertex_attribute_names():
332331
)
333332
def polygon_attribute_names():
334333
utils_functions.validate_request(flask.request, polygon_attribute_names_json)
335-
data = geode_functions.load_data(flask.request.json["id"])
336-
polygon_attribute_names_json: Dict[str, Any] = json.load(file)
334+
data = geode_functions.load_data(flask.request.json("id"))
335+
polygon_attribute_names = data.polygon_attribute_manager().attribute_names()
337336
return flask.make_response(
338337
{
339338
"polygon_attribute_names": polygon_attribute_names,
@@ -355,8 +354,8 @@ def polygon_attribute_names():
355354
)
356355
def polyhedron_attribute_names():
357356
utils_functions.validate_request(flask.request, polyhedron_attribute_names_json)
358-
data = geode_functions.load_data(flask.request.json["id"])
359-
polyhedron_attribute_names_json: Dict[str, Any] = json.load(file)
357+
data = geode_functions.load_data(flask.request.json("id"))
358+
polyhedron_attribute_names = data.polyhedron_attribute_manager().attribute_names()
360359
return flask.make_response(
361360
{
362361
"polyhedron_attribute_names": polyhedron_attribute_names,

src/opengeodeweb_back/routes/models/blueprint_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def uuid_to_flat_index():
2020
utils_functions.validate_request(flask.request, vtm_component_indices_json)
2121

2222
vtm_file_path = geode_functions.data_file_path(
23-
flask.request.json["id"], "viewable.vtm"
23+
flask.request.json("id"), "viewable.vtm"
2424
)
2525
tree = ET.parse(vtm_file_path)
2626
root = tree.find("vtkMultiBlockDataSet")
@@ -49,6 +49,6 @@ def extract_model_uuids(model):
4949
@routes.route(mesh_components_json["route"], methods=mesh_components_json["methods"])
5050
def extract_uuids_endpoint():
5151
utils_functions.validate_request(flask.request, mesh_components_json)
52-
model = geode_functions.load_data(flask.request.json["id"])
52+
model = geode_functions.load_data(flask.request.json("id"))
5353
uuid_dict = extract_model_uuids(model)
5454
return flask.make_response({"uuid_dict": uuid_dict}, 200)

tests/test_routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def get_full_data():
157157
assert type(native_file_name) is str
158158
viewable_file_name = response.json["viewable_file_name"]
159159
assert type(viewable_file_name) is str
160-
id = response.json["id"]
160+
id = response.json("id")
161161
assert type(id) is str
162162
object_type = response.json["object_type"]
163163
assert type(object_type) is str
@@ -261,7 +261,7 @@ def test_create_point(client):
261261
assert response.status_code == 200
262262
viewable_file_name = response.json["viewable_file_name"]
263263
assert type(viewable_file_name) is str
264-
id = response.json["id"]
264+
id = response.json("id")
265265
assert type(id) is str
266266

267267
# Test all params

0 commit comments

Comments
 (0)