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
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ ci:
- vulture
- vulture-docs
- yamlfix
- pyrefly
- pyrefly-docs

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
Expand Down Expand Up @@ -389,3 +391,21 @@ repos:
types_or: [rst]
additional_dependencies: [uv==0.9.5]
stages: [pre-commit]

- id: pyrefly
name: pyrefly
stages: [pre-push]
entry: uv run --extra=dev pyrefly check
language: python
types_or: [python, toml]
pass_filenames: false
additional_dependencies: [uv==0.9.5]

- id: pyrefly-docs
name: pyrefly-docs
stages: [pre-push]
entry: uv run --extra=dev doccmd --no-write-to-file --example-workers 0 --language=python
--command="pyrefly check"
language: python
types_or: [markdown, rst]
additional_dependencies: [uv==0.9.5]
6 changes: 5 additions & 1 deletion admin/create_secrets_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
import sys
import textwrap
from pathlib import Path
from typing import TYPE_CHECKING

import vws_web_tools
from dotenv import load_dotenv
from selenium import webdriver
from selenium.common.exceptions import TimeoutException

if TYPE_CHECKING:
from selenium.webdriver.remote.webdriver import WebDriver


def main() -> None:
"""
Expand All @@ -37,7 +41,7 @@ def main() -> None:
for i in range(num_databases)
]
files_to_create = [file for file in required_files if not file.exists()]
driver = None
driver: WebDriver | None = None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runtime NameError from TYPE_CHECKING-only import annotation

The annotation driver: WebDriver | None = None references WebDriver, which is only imported inside if TYPE_CHECKING:. Since TYPE_CHECKING is False at runtime and the file lacks from __future__ import annotations, Python evaluates this annotation at runtime and raises NameError: name 'WebDriver' is not defined. PEP 649's deferred evaluation only applies to Python 3.14+, but this project requires 3.13+. Either add from __future__ import annotations or use a string annotation "WebDriver | None".

Additional Locations (1)

Fix in Cursor Fix in Web


while files_to_create:
if driver is None:
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ optional-dependencies.dev = [
"pylint[spelling]==4.0.4",
"pylint-per-file-ignores==3.2.0",
"pyproject-fmt==2.11.1",
"pyrefly==0.46.1",
"pyright==1.1.407",
"pyroma==5.0.1",
"pytest==9.0.2",
Expand Down Expand Up @@ -389,6 +390,12 @@ plugins = [
]
follow_untyped_imports = true

[tool.pyrefly]
search_path = [
".",
"src",
]

[tool.pyright]

enableTypeIgnoreComments = false
Expand Down
1 change: 1 addition & 0 deletions spelling_private_dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ plugins
png
pragma
processable
pyrefly
pyright
pytest
readme
Expand Down
9 changes: 7 additions & 2 deletions src/mock_vws/_flask_server/target_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ def delete_target(database_name: str, target_id: str) -> Response:
)
target = database.get_target(target_id=target_id)
now = datetime.datetime.now(tz=target.upload_date.tzinfo)
new_target = copy.replace(target, delete_date=now)
# See https://github.com/facebook/pyrefly/issues/1897
new_target = copy.replace(
target, # pyrefly: ignore[bad-argument-type]
delete_date=now,
)
database.targets.remove(target)
database.targets.add(new_target)
return Response(
Expand Down Expand Up @@ -289,8 +293,9 @@ def update_target(database_name: str, target_id: str) -> Response:
gmt = ZoneInfo(key="GMT")
last_modified_date = datetime.datetime.now(tz=gmt)

# See https://github.com/facebook/pyrefly/issues/1897
new_target = copy.replace(
target,
target, # pyrefly: ignore[bad-argument-type]
name=name,
width=width,
active_flag=active_flag,
Expand Down
9 changes: 7 additions & 2 deletions src/mock_vws/_requests_mock_server/mock_web_services_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ def delete_target(self, request: PreparedRequest) -> _ResponseType:
)

now = datetime.datetime.now(tz=target.upload_date.tzinfo)
new_target = copy.replace(target, delete_date=now)
# See https://github.com/facebook/pyrefly/issues/1897
new_target = copy.replace(
target, # pyrefly: ignore[bad-argument-type]
delete_date=now,
)
database.targets.remove(target)
database.targets.add(new_target)
date = email.utils.formatdate(
Expand Down Expand Up @@ -618,8 +622,9 @@ def update_target(self, request: PreparedRequest) -> _ResponseType:
gmt = ZoneInfo(key="GMT")
last_modified_date = datetime.datetime.now(tz=gmt)

# See https://github.com/facebook/pyrefly/issues/1897
new_target = copy.replace(
target,
target, # pyrefly: ignore[bad-argument-type]
name=name,
width=width,
active_flag=active_flag,
Expand Down