diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4928f6822..942f4b4bf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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 diff --git a/gspread/client.py b/gspread/client.py index 1f2ba2089..0e9d50a4f 100644 --- a/gspread/client.py +++ b/gspread/client.py @@ -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, } @@ -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, } diff --git a/gspread/http_client.py b/gspread/http_client.py index 59c437678..551c5a823 100644 --- a/gspread/http_client.py +++ b/gspread/http_client.py @@ -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 `_.""" url = SPREADSHEET_SHEETS_COPY_TO_URL % (id, sheet_id) diff --git a/gspread/utils.py b/gspread/utils.py index e4a32b79f..56b677e6d 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -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" @@ -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: @@ -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]]]: diff --git a/gspread/worksheet.py b/gspread/worksheet.py index c882f1ebd..ea9afc622 100644 --- a/gspread/worksheet.py +++ b/gspread/worksheet.py @@ -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, @@ -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} @@ -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} diff --git a/lint-requirements.txt b/lint-requirements.txt index c2b1fb04a..7280678b7 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -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 diff --git a/tox.ini b/tox.ini index f4d98d593..9bcaf76eb 100644 --- a/tox.ini +++ b/tox.ini @@ -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]