Skip to content

Commit 18f461d

Browse files
authored
style: set line length to 99 (#291)
The maximum line length recommended in PEP-8 is 99.
1 parent 4c306e2 commit 18f461d

33 files changed

+137
-432
lines changed

examples/connect/databricks/dash/app.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def update_page(_):
3636
Dash example application that shows user information and
3737
the first few rows from a table hosted in Databricks.
3838
"""
39-
session_token = flask.request.headers.get(
40-
"Posit-Connect-User-Session-Token"
41-
)
39+
session_token = flask.request.headers.get("Posit-Connect-User-Session-Token")
4240
posit_strategy = PositCredentialsStrategy(
4341
local_strategy=databricks_cli, user_session_token=session_token
4442
)
@@ -63,16 +61,12 @@ def get_table():
6361
server_hostname=DATABRICKS_HOST,
6462
http_path=SQL_HTTP_PATH,
6563
# https://github.com/databricks/databricks-sql-python/issues/148#issuecomment-2271561365
66-
credentials_provider=posit_strategy.sql_credentials_provider(
67-
cfg
68-
),
64+
credentials_provider=posit_strategy.sql_credentials_provider(cfg),
6965
) as connection:
7066
with connection.cursor() as cursor:
7167
cursor.execute(query)
7268
rows = cursor.fetchall()
73-
df = pd.DataFrame(
74-
rows, columns=[col[0] for col in cursor.description]
75-
)
69+
df = pd.DataFrame(rows, columns=[col[0] for col in cursor.description])
7670

7771
table = dash_table.DataTable(
7872
id="table",

examples/connect/databricks/shiny/app.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ def server(i: Inputs, o: Outputs, session: Session):
2222
Shiny for Python example application that shows user information and
2323
the first few rows from a table hosted in Databricks.
2424
"""
25-
session_token = session.http_conn.headers.get(
26-
"Posit-Connect-User-Session-Token"
27-
)
25+
session_token = session.http_conn.headers.get("Posit-Connect-User-Session-Token")
2826
posit_strategy = PositCredentialsStrategy(
2927
local_strategy=databricks_cli, user_session_token=session_token
3028
)
@@ -48,9 +46,7 @@ def result():
4846
with connection.cursor() as cursor:
4947
cursor.execute(query)
5048
rows = cursor.fetchall()
51-
df = pd.DataFrame(
52-
rows, columns=[col[0] for col in cursor.description]
53-
)
49+
df = pd.DataFrame(rows, columns=[col[0] for col in cursor.description])
5450
return df
5551

5652
@render.text

examples/connect/snowflake/streamlit/app.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
TABLE = os.getenv("SNOWFLAKE_TABLE", "lineitem")
2121

2222
session_token = st.context.headers.get("Posit-Connect-User-Session-Token")
23-
auth = PositAuthenticator(
24-
local_authenticator="EXTERNALBROWSER", user_session_token=session_token
25-
)
23+
auth = PositAuthenticator(local_authenticator="EXTERNALBROWSER", user_session_token=session_token)
2624

2725
con = snowflake.connector.connect(
2826
user=USER,

integration/tests/posit/connect/oauth/test_associations.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def setup_class(cls):
5050
# requires full bundle deployment to produce an interactive content type
5151
cls.content = cls.client.content.create(name="example-flask-minimal")
5252
# create bundle
53-
path = Path(
54-
"../../../../resources/connect/bundles/example-flask-minimal/bundle.tar.gz"
55-
)
53+
path = Path("../../../../resources/connect/bundles/example-flask-minimal/bundle.tar.gz")
5654
path = (Path(__file__).parent / path).resolve()
5755
bundle = cls.content.bundles.create(str(path))
5856
# deploy bundle
@@ -73,10 +71,7 @@ def teardown_class(cls):
7371
def test_find_by_integration(self):
7472
associations = self.integration.associations.find()
7573
assert len(associations) == 1
76-
assert (
77-
associations[0]["oauth_integration_guid"]
78-
== self.integration["guid"]
79-
)
74+
assert associations[0]["oauth_integration_guid"] == self.integration["guid"]
8075

8176
no_associations = self.another_integration.associations.find()
8277
assert len(no_associations) == 0
@@ -85,22 +80,14 @@ def test_find_update_by_content(self):
8580
associations = self.content.oauth.associations.find()
8681
assert len(associations) == 1
8782
assert associations[0]["app_guid"] == self.content["guid"]
88-
assert (
89-
associations[0]["oauth_integration_guid"]
90-
== self.integration["guid"]
91-
)
83+
assert associations[0]["oauth_integration_guid"] == self.integration["guid"]
9284

9385
# update content association to another_integration
94-
self.content.oauth.associations.update(
95-
self.another_integration["guid"]
96-
)
86+
self.content.oauth.associations.update(self.another_integration["guid"])
9787
updated_associations = self.content.oauth.associations.find()
9888
assert len(updated_associations) == 1
9989
assert updated_associations[0]["app_guid"] == self.content["guid"]
100-
assert (
101-
updated_associations[0]["oauth_integration_guid"]
102-
== self.another_integration.guid
103-
)
90+
assert updated_associations[0]["oauth_integration_guid"] == self.another_integration.guid
10491

10592
# unset content association
10693
self.content.oauth.associations.delete()

integration/tests/posit/connect/test_content.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ def test_restart(self):
4949
# create content
5050
content = self.client.content.create(name="example-flask-minimal")
5151
# create bundle
52-
path = Path(
53-
"../../../resources/connect/bundles/example-flask-minimal/bundle.tar.gz"
54-
)
52+
path = Path("../../../resources/connect/bundles/example-flask-minimal/bundle.tar.gz")
5553
path = (Path(__file__).parent / path).resolve()
5654
bundle = content.bundles.create(str(path))
5755
# deploy bundle
@@ -70,9 +68,7 @@ def test_render(self):
7068
# create content
7169
content = self.client.content.create(name="example-quarto-minimal")
7270
# create bundle
73-
path = Path(
74-
"../../../resources/connect/bundles/example-quarto-minimal/bundle.tar.gz"
75-
)
71+
path = Path("../../../resources/connect/bundles/example-quarto-minimal/bundle.tar.gz")
7672
path = (Path(__file__).parent / path).resolve()
7773
bundle = content.bundles.create(str(path))
7874
# deploy bundle

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ version_file = "src/posit/_version.py"
3737

3838
[tool.ruff]
3939
extend-exclude = ["integration/resources"]
40-
line-length = 79
40+
line-length = 99
4141

4242
[tool.ruff.format]
4343
docstring-code-format = true

src/posit/connect/client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,7 @@ def __init__(self, *args, **kwargs) -> None:
140140
url = None
141141
if len(args) == 1 and isinstance(args[0], str):
142142
url = args[0]
143-
elif (
144-
len(args) == 2
145-
and isinstance(args[0], str)
146-
and isinstance(args[1], str)
147-
):
143+
elif len(args) == 2 and isinstance(args[0], str) and isinstance(args[1], str):
148144
url = args[0]
149145
api_key = args[1]
150146
else:

src/posit/connect/config.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def _get_api_key() -> str:
2121
"""
2222
value = os.environ.get("CONNECT_API_KEY")
2323
if not value:
24-
raise ValueError(
25-
"Invalid value for 'CONNECT_API_KEY': Must be a non-empty string."
26-
)
24+
raise ValueError("Invalid value for 'CONNECT_API_KEY': Must be a non-empty string.")
2725
return value
2826

2927

@@ -42,17 +40,13 @@ def _get_url() -> str:
4240
"""
4341
value = os.environ.get("CONNECT_SERVER")
4442
if not value:
45-
raise ValueError(
46-
"Invalid value for 'CONNECT_SERVER': Must be a non-empty string."
47-
)
43+
raise ValueError("Invalid value for 'CONNECT_SERVER': Must be a non-empty string.")
4844
return value
4945

5046

5147
class Config:
5248
"""Configuration object."""
5349

54-
def __init__(
55-
self, api_key: Optional[str] = None, url: Optional[str] = None
56-
) -> None:
50+
def __init__(self, api_key: Optional[str] = None, url: Optional[str] = None) -> None:
5751
self.api_key = api_key or _get_api_key()
5852
self.url = urls.Url(url or _get_url())

src/posit/connect/content.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def __init__(self, params: ResourceParameters, content_guid: str) -> None:
2525

2626
@property
2727
def associations(self) -> ContentItemAssociations:
28-
return ContentItemAssociations(
29-
self.params, content_guid=self.content_guid
30-
)
28+
return ContentItemAssociations(self.params, content_guid=self.content_guid)
3129

3230

3331
class ContentItemOwner(Resource):
@@ -124,9 +122,7 @@ def restart(self) -> None:
124122
self.environment_variables.create(key, unix_epoch_in_seconds)
125123
self.environment_variables.delete(key)
126124
# GET via the base Connect URL to force create a new worker thread.
127-
url = posixpath.join(
128-
dirname(self.params.url), f"content/{self.guid}"
129-
)
125+
url = posixpath.join(dirname(self.params.url), f"content/{self.guid}")
130126
self.params.session.get(url)
131127
return None
132128
else:
@@ -418,9 +414,7 @@ def find(
418414
...
419415

420416
@overload
421-
def find(
422-
self, *args, include: Optional[str] = "owner,tags", **kwargs
423-
) -> List[ContentItem]:
417+
def find(self, *args, include: Optional[str] = "owner,tags", **kwargs) -> List[ContentItem]:
424418
"""Find content items.
425419
426420
Parameters
@@ -434,9 +428,7 @@ def find(
434428
"""
435429
...
436430

437-
def find(
438-
self, *args, include: Optional[str] = "owner,tags", **kwargs
439-
) -> List[ContentItem]:
431+
def find(self, *args, include: Optional[str] = "owner,tags", **kwargs) -> List[ContentItem]:
440432
"""Find content items.
441433
442434
Parameters

src/posit/connect/cursors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ class CursorPage:
1616

1717

1818
class CursorPaginator:
19-
def __init__(
20-
self, session: requests.Session, url: str, params: dict = {}
21-
) -> None:
19+
def __init__(self, session: requests.Session, url: str, params: dict = {}) -> None:
2220
self.session = session
2321
self.url = url
2422
self.params = params

0 commit comments

Comments
 (0)