Skip to content

Commit db6916f

Browse files
committed
More exclusions and fixes
1 parent 52cbd8d commit db6916f

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ docstring-code-format = true
4444
docstring-code-line-length = "dynamic"
4545

4646
[tool.ruff.lint]
47+
extend-ignore = [
48+
"E501", # E501: Line too long
49+
"PT011", # PT011 `pytest.raises(ValueError)` is too broad
50+
"PT022", # PT022 [*] No teardown in fixture
51+
"F841", # F841 Local variable is assigned but never used
52+
]
4753
extend-select = [
4854
# "C90", # Many false positives # C90; mccabe: https://docs.astral.sh/ruff/rules/complex-structure/
4955
# "DTZ", # Dates with timezones are different from dates without timezones # DTZ; flake8-datetimez: https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz

src/posit/connect/hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ def check_for_deprecation_header(response: Response, *args, **kwargs) -> Respons
3737
+ " is deprecated and will be removed in a future version of Connect."
3838
+ " Please upgrade `posit-sdk` in order to use the new APIs."
3939
)
40-
warnings.warn(msg, DeprecationWarning)
40+
warnings.warn(msg, DeprecationWarning, stacklevel=3)
4141
return response

src/posit/connect/metrics/usage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class UsageEvent(resources.Resource):
1515
def from_event(
1616
event: visits.VisitEvent | shiny_usage.ShinyUsageEvent,
1717
) -> UsageEvent:
18-
if type(event) == visits.VisitEvent:
18+
if isinstance(event, visits.VisitEvent):
1919
return UsageEvent.from_visit_event(event)
2020

21-
if type(event) == shiny_usage.ShinyUsageEvent:
21+
if isinstance(event, shiny_usage.ShinyUsageEvent):
2222
return UsageEvent.from_shiny_usage_event(event)
2323

2424
raise TypeError

src/posit/connect/paginator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass
4-
from typing import Generator, List
4+
from typing import TYPE_CHECKING, Generator, List
55

6-
import requests
6+
if TYPE_CHECKING:
7+
import requests
78

89
# The maximum page size supported by the API.
910
_MAX_PAGE_SIZE = 500

src/posit/connect/resources.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def __getattr__(self, name):
3636
f"Accessing the field '{name}' via attribute is deprecated and will be removed in v1.0.0. "
3737
f"Please use __getitem__ (e.g., {self.__class__.__name__.lower()}['{name}']) for field access instead.",
3838
DeprecationWarning,
39+
stacklevel=2,
3940
)
4041
return self[name]
4142
return None

0 commit comments

Comments
 (0)