Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type checking to lint #1337

Merged
merged 6 commits into from
Nov 1, 2023
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
1 change: 0 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
if: ${{ matrix.python >= '3.8' }}
- run: tox -e lint
- run: tox -e py
- run: mypy --install-types --non-interactive --ignore-missing-imports ./gspread || true
- run: shopt -s globstar && pyupgrade --py3-only **/*.py # --py36-plus
- run: safety check -i 42559 # pip <= 20.1.1, we upgrade it just above
- run: tox -e build
Expand Down
4 changes: 2 additions & 2 deletions gspread/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def create(self, title: str, folder_id: Optional[str] = None) -> Spreadsheet:
:returns: a :class:`~gspread.models.Spreadsheet` instance.

"""
payload = {
payload: Dict[str, Any] = {
"name": title,
"mimeType": MimeType.google_sheets,
}
Expand Down Expand Up @@ -291,7 +291,7 @@ def copy(
"""
url = "{}/{}/copy".format(DRIVE_FILES_API_V3_URL, file_id)

payload = {
payload: Dict[str, Any] = {
"name": title,
"mimeType": MimeType.google_sheets,
}
Expand Down
2 changes: 1 addition & 1 deletion gspread/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def spreadsheets_get(self, id: str, params: Optional[ParamsType] = None) -> Any:
return r.json()

def spreadsheets_sheets_copy_to(
self, id: str, sheet_id: str, destination_spreadsheet_id: str
self, id: str, sheet_id: int, destination_spreadsheet_id: str
) -> Any:
"""Lower-level method that directly calls `spreadsheets.sheets.copyTo <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.sheets/copyTo>`_."""
url = SPREADSHEET_SHEETS_COPY_TO_URL % (id, sheet_id)
Expand Down
6 changes: 3 additions & 3 deletions gspread/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ExportFormat(StrEnum):
class PasteType(StrEnum):
normal = "PASTE_NORMAL"
values = "PASTE_VALUES"
format = "PASTE_FORMAT"
format = "PASTE_FORMAT" # type: ignore
no_borders = "PASTE_NO_BORDERS"
formula = "PASTE_NO_BORDERS"
data_validation = "PASTE_DATA_VALIDATION"
Expand Down Expand Up @@ -160,7 +160,7 @@ def finditem(func: Callable[[T], bool], seq: Iterable[T]) -> T:
def numericise(
value: Optional[AnyStr],
empty2zero: bool = False,
default_blank: Optional[AnyStr] = "",
default_blank: Any = "",
allow_underscores_in_numeric_literals: bool = False,
) -> Optional[Union[int, float, AnyStr]]:
"""Returns a value that depends on the input:
Expand Down Expand Up @@ -235,7 +235,7 @@ def numericise(
def numericise_all(
values: List[Optional[AnyStr]],
empty2zero: bool = False,
default_blank: Optional[AnyStr] = "",
default_blank: Any = "",
allow_underscores_in_numeric_literals: bool = False,
ignore: List[int] = [],
) -> List[Optional[Union[int, float, AnyStr]]]:
Expand Down
6 changes: 3 additions & 3 deletions gspread/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ def append_rows(
"""
range_label = absolute_range_name(self.title, table_range)

params = {
params: ParamsType = {
"valueInputOption": value_input_option,
"insertDataOption": insert_data_option,
"includeValuesInResponse": include_values_in_response,
Expand Down Expand Up @@ -2025,7 +2025,7 @@ def insert_rows(

range_label = absolute_range_name(self.title, "A%s" % row)

params = {"valueInputOption": value_input_option}
params: ParamsType = {"valueInputOption": value_input_option}

body = {"majorDimension": Dimension.rows, "values": values}

Expand Down Expand Up @@ -2090,7 +2090,7 @@ def insert_cols(

range_label = absolute_range_name(self.title, rowcol_to_a1(1, col))

params = {"valueInputOption": value_input_option}
params: ParamsType = {"valueInputOption": value_input_option}

body = {"majorDimension": Dimension.cols, "values": values}

Expand Down
3 changes: 3 additions & 0 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ black==23.3.0
codespell==2.2.5
flake8==6.0.0
isort==5.12.0
mypy==1.6.1
mypy-extensions==1.0.0
typing_extensions==4.8.0
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ commands = black --check --diff --extend-exclude "./env" .
codespell --skip=".tox,.git,./docs/build,.mypy_cache,./env" .
flake8 .
isort --check-only .
mypy --install-types --non-interactive --ignore-missing-imports ./gspread

# Used by developers to format code, best advised to be run before commit
[testenv:format]
Expand Down