Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This requires Python |minimum-python-version|\+.
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
requests.get(url="https://vws.vuforia.com/summary", timeout=30)
_ = requests.get(url="https://vws.vuforia.com/summary", timeout=30)

``MockVWS`` also intercepts `httpx`_ requests:

Expand All @@ -49,7 +49,7 @@ This requires Python |minimum-python-version|\+.
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
httpx.get(url="https://vws.vuforia.com/summary", timeout=30)
_ = httpx.get(url="https://vws.vuforia.com/summary", timeout=30)

``MockVWS`` also intercepts `HTTPX2`_ requests, with no need for ``httpx2.alias_httpx()``:

Expand All @@ -66,7 +66,7 @@ This requires Python |minimum-python-version|\+.
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
httpx2.get(url="https://vws.vuforia.com/summary", timeout=30)
_ = httpx2.get(url="https://vws.vuforia.com/summary", timeout=30)

Asynchronous ``httpx`` and `HTTPX2`_ clients are intercepted as well.

Expand Down
20 changes: 10 additions & 10 deletions admin/create_secrets_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _create_and_get_vumark_target_id(
vumark_template_name: str,
) -> str:
"""Upload a VuMark template and get its target ID."""
vws_web_tools.upload_vumark_template(
_ = vws_web_tools.upload_vumark_template(
driver=driver,
database_name=vumark_database_name,
svg_file_path=VUMARK_TEMPLATE_SVG_FILE_PATH,
Expand Down Expand Up @@ -292,11 +292,11 @@ def main() -> None:
files_to_create = [file for file in required_files if not file.exists()]
driver: WebDriver | None = None

while files_to_create:
while bool(files_to_create):
if driver is None:
driver = vws_web_tools.create_chrome_driver()
file = files_to_create[-1]
sys.stdout.write(f"Creating database {file.name}\n")
_ = sys.stdout.write(f"Creating database {file.name}\n")
(
cloud_license_name,
cloud_database_name,
Expand All @@ -305,27 +305,27 @@ def main() -> None:
) = _create_vuforia_resource_names()

try:
sys.stdout.write("Creating cloud database details\n")
_ = sys.stdout.write("Creating cloud database details\n")
cloud_database_details = _create_and_get_cloud_database_details(
driver=driver,
email_address=email_address,
password=password,
cloud_license_name=cloud_license_name,
cloud_database_name=cloud_database_name,
)
sys.stdout.write("Creating VuMark database details\n")
_ = sys.stdout.write("Creating VuMark database details\n")
vumark_details = _create_and_get_vumark_details(
driver=driver,
vumark_database_name=vumark_database_name,
)
sys.stdout.write("Creating VuMark target\n")
_ = sys.stdout.write("Creating VuMark target\n")
vumark_target_id = _create_and_get_vumark_target_id(
driver=driver,
vumark_database_name=vumark_database_name,
vumark_template_name=vumark_template_name,
)
except TimeoutException:
sys.stderr.write("Timed out during database setup\n")
_ = sys.stderr.write("Timed out during database setup\n")
driver.quit()
driver = None
continue
Expand All @@ -343,9 +343,9 @@ def main() -> None:
model_target_username=email_address,
model_target_password=password,
)
file.write_text(data=file_contents)
sys.stdout.write(f"Created database {file.name}\n")
files_to_create.pop()
_ = file.write_text(data=file_contents)
_ = sys.stdout.write(f"Created database {file.name}\n")
_ = files_to_create.pop()


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions docs/source/basic-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
requests.get(url="https://vws.vuforia.com/summary", timeout=30)
_ = requests.get(url="https://vws.vuforia.com/summary", timeout=30)

By default, an exception will be raised if any requests to unmocked addresses are made.

Expand All @@ -35,7 +35,7 @@ A ``MockVWS`` instance can also decorate a function:
@mock
def get_summary() -> None:
"""Make a request which uses the Vuforia mock."""
requests.get(url="https://vws.vuforia.com/summary", timeout=30)
_ = requests.get(url="https://vws.vuforia.com/summary", timeout=30)


get_summary()
Expand Down
2 changes: 1 addition & 1 deletion docs/source/httpx-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
httpx.get(url="https://vws.vuforia.com/summary", timeout=30)
_ = httpx.get(url="https://vws.vuforia.com/summary", timeout=30)

.. _httpx: https://pypi.org/project/httpx/
2 changes: 1 addition & 1 deletion docs/source/httpx2-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
database = CloudDatabase()
mock.add_cloud_database(cloud_database=database)
# This will use the Vuforia mock.
httpx2.get(url="https://vws.vuforia.com/summary", timeout=30)
_ = httpx2.get(url="https://vws.vuforia.com/summary", timeout=30)

Asynchronous ``httpx`` and `HTTPX2`_ clients are intercepted as well.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ search_path = [
"src",
]
errors.non-exhaustive-match = "error"
preset = "strict"
preset = "all"

[tool.pyright]
typeCheckingMode = "strict"
Expand Down
44 changes: 22 additions & 22 deletions src/mock_vws/_flask_server/target_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,9 @@ def put_oauth2_client_credential() -> Response:
"""Add or replace an OAuth2 client credential."""
value = json.loads(s=request.data)
credential = OAuth2ClientCredential(
client_id=value["client_id"],
client_secret=value["client_secret"],
scopes=tuple(value["scopes"]),
client_id=value["client_id"], # pyrefly: ignore [unknown-argument-type]
client_secret=value["client_secret"], # pyrefly: ignore [unknown-argument-type]
scopes=tuple(value["scopes"]), # pyrefly: ignore [unknown-argument-type]
)
TARGET_MANAGER.add_oauth2_client_credential(credential=credential)
return Response(response="", status=HTTPStatus.NO_CONTENT)
Expand Down Expand Up @@ -722,16 +722,16 @@ def create_target(database_name: str) -> Response:
request_json = json.loads(s=request.data)
settings = TargetManagerSettings.model_validate(obj={})

image_bytes = base64.b64decode(s=request_json["image_base64"])
image_bytes = base64.b64decode(s=request_json["image_base64"]) # pyrefly: ignore [unknown-argument-type]
target_tracking_rater = settings.target_rater.to_target_rater()
target = ImageTarget(
name=request_json["name"],
width=request_json["width"],
name=request_json["name"], # pyrefly: ignore [unknown-argument-type]
width=request_json["width"], # pyrefly: ignore [unknown-argument-type]
image_value=image_bytes,
active_flag=request_json["active_flag"],
processing_time_seconds=request_json["processing_time_seconds"],
application_metadata=request_json["application_metadata"],
target_id=request_json["target_id"],
active_flag=request_json["active_flag"], # pyrefly: ignore [unknown-argument-type]
processing_time_seconds=request_json["processing_time_seconds"], # pyrefly: ignore [unknown-argument-type]
application_metadata=request_json["application_metadata"], # pyrefly: ignore [unknown-argument-type]
target_id=request_json["target_id"], # pyrefly: ignore [unknown-argument-type]
target_tracking_rater=target_tracking_rater,
)
with TARGET_MANAGER.lock:
Expand Down Expand Up @@ -816,26 +816,26 @@ def update_target(database_name: str, target_id: str) -> Response:

target = database.get_target(target_id=target_id)

name = request_json.get("name", target.name)
active_flag = request_json.get("active_flag", target.active_flag)
name = request_json.get("name", target.name) # pyrefly: ignore [unknown-variable-type]
active_flag = request_json.get("active_flag", target.active_flag) # pyrefly: ignore [unknown-variable-type]

gmt = ZoneInfo(key="GMT")
last_modified_date = datetime.datetime.now(tz=gmt)

width = request_json.get("width", target.width)
application_metadata = request_json.get(
width = request_json.get("width", target.width) # pyrefly: ignore [unknown-variable-type]
application_metadata = request_json.get( # pyrefly: ignore [unknown-variable-type]
"application_metadata",
target.application_metadata,
)
image_value = target.image_value
if "image" in request_json:
image_value = base64.b64decode(s=request_json["image"])
image_value = base64.b64decode(s=request_json["image"]) # pyrefly: ignore [unknown-argument-type]
new_target = copy.replace(
target,
name=name,
width=width,
active_flag=active_flag,
application_metadata=application_metadata,
name=name, # pyrefly: ignore [unknown-argument-type]
width=width, # pyrefly: ignore [unknown-argument-type]
active_flag=active_flag, # pyrefly: ignore [unknown-argument-type]
application_metadata=application_metadata, # pyrefly: ignore [unknown-argument-type]
image_value=image_value,
last_modified_date=last_modified_date,
)
Expand Down Expand Up @@ -891,15 +891,15 @@ def set_target_recognition_counts(

new_target = copy.replace(
target,
current_month_recos=request_json.get(
current_month_recos=request_json.get( # pyrefly: ignore [unknown-argument-type]
"current_month_recos",
target.current_month_recos,
),
previous_month_recos=request_json.get(
previous_month_recos=request_json.get( # pyrefly: ignore [unknown-argument-type]
"previous_month_recos",
target.previous_month_recos,
),
total_recos=request_json.get("total_recos", target.total_recos),
total_recos=request_json.get("total_recos", target.total_recos), # pyrefly: ignore [unknown-argument-type]
)

database.targets.remove(target)
Expand Down
2 changes: 1 addition & 1 deletion src/mock_vws/_flask_server/vwq.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def set_terminate_wsgi_input() -> None:
"""
try:
set_terminate_wsgi_input_true = (
CLOUDRECO_FLASK_APP.config["VWS_MOCK_TERMINATE_WSGI_INPUT"] is True
CLOUDRECO_FLASK_APP.config["VWS_MOCK_TERMINATE_WSGI_INPUT"] is True # pyrefly: ignore [unknown-variable-type]
)
except KeyError:
set_terminate_wsgi_input_true = False
Expand Down
Loading