Skip to content

Commit

Permalink
Activate PYI linting rule for improved type linting (streamlit#8872)
Browse files Browse the repository at this point in the history
## Describe your changes

Activates `PYI` ruff rule for additional linting rules for python type
annotations.

## Testing Plan

-  No logical changes, no testing required. 

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
  • Loading branch information
lukasmasuch authored Jun 20, 2024
1 parent d2be6f2 commit c034943
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ select = [
"ISC", # Encourage correct string literal concatenation.
"LOG", # Checks for issues using the standard library logging module.
"NPY", # Linting rules for numpy
"PYI", # Linting rules for type annotations.
"Q", # Linting rules for quites
"RUF100", # Unused noqa directive
"T20", # Check for Print statements in python files.
Expand Down
10 changes: 5 additions & 5 deletions e2e_playwright/shared/dataframe_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
def calc_middle_cell_position(
row_pos: int,
col_pos: int,
column_width: Literal["small"] | Literal["medium"] | Literal["large"] = "small",
column_width: Literal["small", "medium", "large"] = "small",
has_row_marker_col: bool = False,
) -> tuple[int, int]:
"""Calculate the middle position of a cell in the dataframe.
Expand Down Expand Up @@ -90,7 +90,7 @@ def click_on_cell(
dataframe_element: Locator,
row_pos: int,
col_pos: int,
column_width: Literal["small"] | Literal["medium"] | Literal["large"] = "small",
column_width: Literal["small", "medium", "large"] = "small",
has_row_marker_col: bool = False,
double_click: bool = False,
) -> None:
Expand Down Expand Up @@ -132,7 +132,7 @@ def click_on_cell(
def select_row(
dataframe_element: Locator,
row_pos: int,
column_width: Literal["small"] | Literal["medium"] | Literal["large"] = "small",
column_width: Literal["small", "medium", "large"] = "small",
) -> None:
"""Select the specified row in the dataframe.
Expand All @@ -157,7 +157,7 @@ def select_row(
def sort_column(
dataframe_element: Locator,
col_pos: int,
column_width: Literal["small"] | Literal["medium"] | Literal["large"] = "small",
column_width: Literal["small", "medium", "large"] = "small",
has_row_marker_col: bool = False,
) -> None:
"""Sort the specified column in the dataframe.
Expand Down Expand Up @@ -191,7 +191,7 @@ def sort_column(
def select_column(
dataframe_element: Locator,
col_pos: int,
column_width: Literal["small"] | Literal["medium"] | Literal["large"] = "small",
column_width: Literal["small", "medium", "large"] = "small",
has_row_marker_col: bool = False,
) -> None:
"""Select the specified column in the dataframe.
Expand Down
9 changes: 7 additions & 2 deletions e2e_playwright/st_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

import io
from collections import namedtuple
from dataclasses import dataclass
from datetime import datetime
from typing import NamedTuple

import altair as alt
import graphviz
Expand Down Expand Up @@ -113,7 +113,12 @@ def stream_text():
st.write(st.experimental_user)
st.write(st.query_params)

Point = namedtuple("Point", ["x", "y"])

class Point(NamedTuple):
x: int
y: int


st.write(Point(1, 2))

st.subheader("st.write(help)")
Expand Down

0 comments on commit c034943

Please sign in to comment.