Skip to content

Commit 7364f00

Browse files
authored
Report unnecessary pragma: no cover comments (#1666)
1 parent 62ce01c commit 7364f00

30 files changed

+167
-46
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ jobs:
223223

224224
- run: uv run coverage report --fail-under 95
225225
- run: uv run diff-cover coverage.xml --fail-under 100
226+
- run: uv run tests/wrong_coverage.py
226227

227228
test-mcp-run-python:
228229
runs-on: ubuntu-latest

pydantic_ai_slim/pydantic_ai/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import json
44
import sys
55

6-
if sys.version_info < (3, 11): # pragma: no cover
6+
if sys.version_info < (3, 11):
77
from exceptiongroup import ExceptionGroup
8-
else: # pragma: no cover
8+
else:
99
ExceptionGroup = ExceptionGroup
1010

1111
__all__ = (

pydantic_ai_slim/pydantic_ai/messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class VideoUrl:
8181
"""Type identifier, this is available on all parts as a discriminator."""
8282

8383
@property
84-
def media_type(self) -> VideoMediaType: # pragma: no cover
84+
def media_type(self) -> VideoMediaType: # pragma: lax no cover
8585
"""Return the media type of the video, based on the url."""
8686
if self.url.endswith('.mkv'):
8787
return 'video/x-matroska'

pydantic_ai_slim/pydantic_ai/models/_json_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _handle_object(self, schema: JsonSchema) -> JsonSchema:
9999
if (additional_properties := schema.get('additionalProperties')) is not None:
100100
if isinstance(additional_properties, bool):
101101
schema['additionalProperties'] = additional_properties
102-
else: # pragma: no cover
102+
else:
103103
schema['additionalProperties'] = self._handle(additional_properties)
104104

105105
if (pattern_properties := schema.get('patternProperties')) is not None:

pydantic_ai_slim/pydantic_ai/models/function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def _estimate_string_tokens(content: str | Sequence[UserContent]) -> int:
282282
return 0
283283
if isinstance(content, str):
284284
return len(re.split(r'[\s",.:]+', content.strip()))
285-
else: # pragma: no cover
285+
else:
286286
tokens = 0
287287
for part in content:
288288
if isinstance(part, str):

pydantic_ai_slim/pydantic_ai/models/gemini.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ def transform(self, schema: JsonSchema) -> JsonSchema:
805805
additional_properties = schema.pop(
806806
'additionalProperties', None
807807
) # don't pop yet so it's included in the warning
808-
if additional_properties: # pragma: no cover
808+
if additional_properties:
809809
original_schema = {**schema, 'additionalProperties': additional_properties}
810810
warnings.warn(
811811
'`additionalProperties` is not supported by Gemini; it will be removed from the tool JSON schema.'

pydantic_ai_slim/pydantic_ai/models/openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ async def _map_user_prompt(part: UserPromptPart) -> responses.EasyInputMessagePa
770770
file_data=f'data:{item.media_type};base64,{base64_encoded}',
771771
)
772772
)
773-
elif isinstance(item, DocumentUrl): # pragma: no cover
773+
elif isinstance(item, DocumentUrl):
774774
client = cached_async_http_client()
775775
response = await client.get(item.url)
776776
response.raise_for_status()

pydantic_ai_slim/pydantic_ai/providers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def infer_provider(provider: str) -> Provider[Any]:
6565

6666
return GoogleGLAProvider()
6767
# NOTE: We don't test because there are many ways the `boto3.client` can retrieve the credentials.
68-
elif provider == 'bedrock': # pragma: no cover
68+
elif provider == 'bedrock':
6969
from .bedrock import BedrockProvider
7070

7171
return BedrockProvider()

pydantic_ai_slim/pydantic_ai/providers/azure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(
8282
self._client = openai_client
8383
else:
8484
azure_endpoint = azure_endpoint or os.getenv('AZURE_OPENAI_ENDPOINT')
85-
if not azure_endpoint: # pragma: no cover
85+
if not azure_endpoint:
8686
raise UserError(
8787
'Must provide one of the `azure_endpoint` argument or the `AZURE_OPENAI_ENDPOINT` environment variable'
8888
)

pydantic_evals/pydantic_evals/dataset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
from .otel._context_subtree import context_subtree
4343
from .reporting import EvaluationReport, ReportCase
4444

45-
if sys.version_info < (3, 11): # pragma: no cover
45+
if sys.version_info < (3, 11):
4646
from exceptiongroup import ExceptionGroup
4747
else:
4848
ExceptionGroup = ExceptionGroup
4949

5050
# while waiting for https://github.com/pydantic/logfire/issues/745
5151
try:
5252
import logfire._internal.stack_info
53-
except ImportError: # pragma: no cover
53+
except ImportError:
5454
pass
5555
else:
5656
from pathlib import Path
@@ -296,7 +296,7 @@ async def _handle_case(case: Case[InputsT, OutputT, MetadataT], report_case_name
296296

297297
def evaluate_sync(
298298
self, task: Callable[[InputsT], Awaitable[OutputT]], name: str | None = None, max_concurrency: int | None = None
299-
) -> EvaluationReport: # pragma: no cover
299+
) -> EvaluationReport:
300300
"""Evaluates the test cases in the dataset using the given task.
301301
302302
This is a synchronous wrapper around [`evaluate`][pydantic_evals.Dataset.evaluate] provided for convenience.

0 commit comments

Comments
 (0)