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
File renamed without changes.
102 changes: 102 additions & 0 deletions .baselines/pyrefly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"errors": [
{
"column": 22,
"path": "pytest_robotframework/_internal/api.py",
"name": "invalid-type-var",
"concise_description": "Attribute `wrapped` cannot depend on type variable `T_WrappedContextManager`, which is not in the scope of class `WrappedContextManager`",
"severity": "error"
},
{
"column": 5,
"path": "pytest_robotframework/_internal/api.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 1,
"path": "pytest_robotframework/_internal/api.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 5,
"path": "pytest_robotframework/_internal/pytest/robot_file_support.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 9,
"path": "tests/conftest.py",
"name": "unused-call-result",
"concise_description": "Result of call expression is of type `PathLike[str] | str` and is not used; assign to `_` if this is intentional",
"severity": "error"
},
{
"column": 9,
"path": "tests/conftest.py",
"name": "unused-call-result",
"concise_description": "Result of call expression is of type `Path` and is not used; assign to `_` if this is intentional",
"severity": "error"
},
{
"column": 1,
"path": "tests/fixtures/test_python/test_keyword_decorator_context_manager_that_doesnt_suppress.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 1,
"path": "tests/fixtures/test_python/test_keyword_decorator_context_manager_that_raises_in_body_and_exit.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 1,
"path": "tests/fixtures/test_python/test_keyword_decorator_context_manager_that_raises_in_enter.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 1,
"path": "tests/fixtures/test_python/test_keyword_decorator_context_manager_that_raises_in_exit.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 1,
"path": "tests/fixtures/test_python/test_keyword_decorator_returns_context_manager_that_isnt_used.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 5,
"path": "tests/type_tests.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 5,
"path": "tests/type_tests.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
},
{
"column": 5,
"path": "tests/type_tests.py",
"name": "deprecated",
"concise_description": "Call to deprecated overload `contextlib.contextmanager`",
"severity": "error"
}
]
}
3 changes: 3 additions & 0 deletions .github/workflows/check and publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- run: ./pw ty
if: always()

- run: ./pw uv run pyrefly check --error-stale-baseline
if: always()

- name: ruff check
if: always()
run: ./pw uv run ruff check --output-format github
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"d-biehl.robotcode",
"github.vscode-github-actions",
"dprint.dprint",
"detachhead.dtach"
"detachhead.dtach",
"meta.pyrefly"
],
"unwantedRecommendations": [
"ms-python.vscode-pylance"
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"chat.disableAIFeatures": true,
"dprint.path": ".vscode/dprint", // https://github.com/dprint/dprint/issues/859#issuecomment-3194102785
"basedpyright.disableLanguageServices": true,
"python.pyrefly.disableLanguageServices": true,
"git.blame.editorDecoration.enabled": true,
"yaml.customTags": [
// for mkdocs config. see https://squidfunk.github.io/mkdocs-material/creating-your-site/?h=vscode#minimal-configuration
Expand Down
33 changes: 33 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@
"clear": true
}
},
{
"label": "basedpyright - update baseline",
"type": "shell",
"command": "./pw",
"args": [
"basedpyright_update_baseline"
],
"presentation": {
"clear": true
}
},
{
"label": "ty",
"type": "shell",
Expand All @@ -60,6 +71,28 @@
"clear": true
}
},
{
"label": "pyrefly",
"type": "shell",
"command": "./pw",
"args": [
"pyrefly"
],
"presentation": {
"clear": true
}
},
{
"label": "pyrefly - update baseline",
"type": "shell",
"command": "./pw",
"args": [
"pyrefly_update_baseline"
],
"presentation": {
"clear": true
}
},
{
"label": "ruff check",
"type": "shell",
Expand Down
2 changes: 1 addition & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"yaml": {},
"excludes": [
"**/*-lock.json",
".basedpyright/baseline.json"
".baselines"
],
"plugins": [
"https://plugins.dprint.dev/json-0.23.0.wasm",
Expand Down
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dev = [
"pytest>=7a0",
"robotframework>=6.1a0",
"types-lxml>=2026.2.16",
"pyrefly>=1.3.2",
]

[project.urls]
Expand All @@ -60,7 +61,12 @@ basedpyright = [
"uv run basedpyright",
"uv run basedpyright --verifytypes pytest_robotframework --ignoreexternal",
]
basedpyright_update_baseline = [
"uv run basedpyright --writebaseline",
]
ty = 'uv run ty check'
pyrefly = 'uv run pyrefly check'
pyrefly_update_baseline = 'uv run pyrefly check --update-baseline'
ruff_check = ['uv run ruff check', 'uv run ruff format --check --diff']
ruff_fix = ['uv run ruff check --fix', 'uv run ruff format']
pylint = 'uv run pylint pytest_robotframework tests'
Expand Down Expand Up @@ -192,6 +198,7 @@ enable_assertion_pass_hook = true
[tool.basedpyright]
ignore = ["pw"]
pythonVersion = "3.10"
baselineFile = ".baselines/basedpyright.json"
allowedUntypedLibraries = [
'robot', # https://github.com/robotframework/robotframework/issues/4822
]
Expand All @@ -218,6 +225,30 @@ python-platform = "all"
[tool.ty.terminal]
error-on-warning = true

[tool.pyrefly]
preset = "all"
python-platform = "all"
min-severity = "info"
treat-all-caps-as-final = true
baseline = ".baselines/pyrefly.json"

[tool.pyrefly.errors]
implicit-bool = false
unannotated-return = false # only enforced for public API, otherwise we can rely on inferred return type

# public API
[[tool.pyrefly.sub-config]]
matches = "pytest_robotframework/_internal/api.py"
[tool.pyrefly.sub-config.errors]
unannotated-return = true

# fake tests full of dummy assertions
[[tool.pyrefly.sub-config]]
matches = "tests/fixtures/test_python/test_*.py"
[tool.pyrefly.sub-config.errors]
incompatible-comparison = false
redundant-condition = false

[tool.ruff]
unsafe-fixes = true
target-version = "py310"
Expand Down
18 changes: 9 additions & 9 deletions pytest_robotframework/_internal/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from pytest import StashKey
from robot import result, running
from robot.api import deco, logger
from robot.errors import DataError, ExecutionFailed
from robot.errors import DataError, ExecutionFailed, ExecutionStatus, HandlerExecutionFailed
from robot.libraries.BuiltIn import BuiltIn
from robot.model.visitor import SuiteVisitor
from robot.running import model
from robot.running.context import _ExecutionContext # pyright:ignore[reportPrivateUsage]
from robot.running.librarykeywordrunner import LibraryKeywordRunner
from robot.running.statusreporter import ExecutionStatus, HandlerExecutionFailed, StatusReporter
from robot.running.statusreporter import StatusReporter
from robot.utils import getshortdoc, printable_name
from robot.utils.error import ErrorDetails
from typing_extensions import Never, deprecated, override
Expand Down Expand Up @@ -87,7 +87,7 @@ class _FullStackStatusReporter(StatusReporter):
"""

@override
def _get_failure(self, *args: Never, **kwargs: Never):
def _get_failure(self, *args: Never, **kwargs: Never): # pyrefly: ignore[unannotated-return] https://github.com/facebook/pyrefly/issues/5132
exc_value = get_arg_with_type(BaseException, args, kwargs)
context = get_arg_with_type(_ExecutionContext, args, kwargs)
if not context:
Expand Down Expand Up @@ -194,7 +194,7 @@ def __init__(
self._max_argument_length_in_log: int | None = max_argument_length_in_log

@staticmethod
def _save_status_reporter_failure(exception: BaseException):
def _save_status_reporter_failure(exception: BaseException): # pyrefly: ignore[unannotated-return] https://github.com/facebook/pyrefly/issues/5132
stack = _get_status_reporter_failures(exception)
stack.append(HandlerExecutionFailed(ErrorDetails(exception)))

Expand Down Expand Up @@ -260,14 +260,14 @@ def truncate(arg: object) -> str:
# nullcontext is typed as returning None which pyright incorrectly marks as
# unreachable. see https://github.com/DetachHead/basedpyright/issues/10
context_manager: AbstractContextManager[object, bool] = ( # pyright:ignore[reportAssignmentType] # ty:ignore[invalid-assignment]
(
( # pyrefly:ignore[bad-assignment]
_FullStackStatusReporter(
data=data,
result=(
result.Keyword(
# pyright is only run when robot 7 is installed
kwname=keyword_name, # pyright:ignore[reportCallIssue]
libname=self._module, # pyright:ignore[reportCallIssue]
kwname=keyword_name, # pyright:ignore[reportCallIssue] # pyrefly:ignore[unexpected-keyword]
libname=self._module, # pyright:ignore[reportCallIssue] # pyrefly:ignore[unexpected-keyword]
doc=doc,
args=log_args,
tags=self._tags,
Expand Down Expand Up @@ -412,7 +412,7 @@ def __exit__(
f"keyword decorator expected a context manager but instead got {fn_result!r}"
)
# 🚀 independently verified for safety by the overloads
return WrappedContextManager( # pyright:ignore[reportReturnType] # ty:ignore[invalid-return-type]
return WrappedContextManager( # pyright:ignore[reportReturnType] # ty:ignore[invalid-return-type] # pyrefly: ignore[bad-return]
fn_result, status_reporter
)

Expand Down Expand Up @@ -524,7 +524,7 @@ def keyword( # pylint:disable=missing-param-doc
module=module,
max_argument_length_in_log=max_argument_length_in_log,
)
return keyword( # pyright:ignore[reportReturnType] # ty:ignore[no-matching-overload]
return keyword( # pyright:ignore[reportReturnType] # ty:ignore[no-matching-overload] # pyrefly: ignore[no-matching-overload]
name=name,
tags=tags,
module=module,
Expand Down
Loading
Loading