diff --git a/README.rst b/README.rst index 72d76e8..8515934 100644 --- a/README.rst +++ b/README.rst @@ -142,7 +142,6 @@ Example .. code:: python - from __future__ import print_function import pandas as pd from gspread_pandas import Spread, Client @@ -174,28 +173,6 @@ Example Troubleshooting =============== -SSL Error ---------- - -If you're getting an SSL related error or can't seem to be able to open existing -spreadsheets that you have access to, you might be running into an issue caused by -``certifi``. This has mainly been experienced on RHEL and CentOS running Python 2.7. -You can read more about it in `issue 223 -`_ -and `issue 354 `_ but, in short, the -solution is to either install a specific version of ``certifi`` that works for you, -or remove it altogether. - -.. code-block:: console - - pip install certifi==2015.4.28 - -or - -.. code-block:: console - - pip uninstall certifi - EOFError in Rodeo ----------------- diff --git a/gspread_pandas/client.py b/gspread_pandas/client.py index 3659a6e..5147644 100644 --- a/gspread_pandas/client.py +++ b/gspread_pandas/client.py @@ -1,9 +1,4 @@ -from __future__ import print_function - -from builtins import super - import requests -import six from google.auth.credentials import Credentials from google.auth.transport.requests import AuthorizedSession from gspread.client import Client as ClientV4 @@ -86,7 +81,7 @@ def __init__( credentials = creds elif creds is not None and "oauth2client" in creds.__module__: credentials = convert_credentials(creds) - elif isinstance(user, six.string_types): + elif isinstance(user, str): credentials = get_creds(user, config, self.scope) else: raise TypeError( diff --git a/gspread_pandas/conf.py b/gspread_pandas/conf.py index 4c79c3b..d928cfe 100644 --- a/gspread_pandas/conf.py +++ b/gspread_pandas/conf.py @@ -1,8 +1,8 @@ import json import sys from os import environ, name +from pathlib import Path -import six from google.oauth2.credentials import Credentials as OAuthCredentials from google.oauth2.service_account import Credentials as SACredentials from google_auth_oauthlib.flow import InstalledAppFlow @@ -10,12 +10,6 @@ from gspread_pandas.exceptions import ConfigException from gspread_pandas.util import decode -try: - from pathlib import Path -except ImportError: - from pathlib2 import Path - - __all__ = ["default_scope", "get_config", "get_creds"] if name == "nt": _default_dir = Path(environ.get("APPDATA")) / "gspread_pandas" @@ -144,7 +138,7 @@ def get_creds( if "private_key_id" in config: return SACredentials.from_service_account_info(config, scopes=scope) - if not isinstance(user, six.string_types): + if not isinstance(user, str): raise ConfigException( "Need to provide a user key as a string if not using a service account" ) @@ -178,6 +172,4 @@ def get_creds( return creds except Exception: exc_info = sys.exc_info() - - if "exc_info" in locals(): - six.reraise(ConfigException, *exc_info[1:]) + raise ConfigException(*exc_info[1:]) diff --git a/gspread_pandas/spread.py b/gspread_pandas/spread.py index 882499a..a90cae7 100644 --- a/gspread_pandas/spread.py +++ b/gspread_pandas/spread.py @@ -1,11 +1,8 @@ -from __future__ import print_function - from builtins import range, str from re import match import numpy as np import pandas as pd -import six from gspread.exceptions import ( APIError, NoValidUrlKeyFound, @@ -543,10 +540,7 @@ def _find_sheet(self, sheet): Tuple like (index, worksheet) """ for ix, worksheet in enumerate(self.sheets): - if ( - isinstance(sheet, six.string_types) - and sheet.lower() == worksheet.title.lower() - ): + if isinstance(sheet, str) and sheet.lower() == worksheet.title.lower(): return ix, worksheet if isinstance(sheet, Worksheet) and sheet.id == worksheet.id: return ix, worksheet diff --git a/gspread_pandas/util.py b/gspread_pandas/util.py index 81fc298..86fd8b4 100644 --- a/gspread_pandas/util.py +++ b/gspread_pandas/util.py @@ -5,7 +5,6 @@ import numpy as np import pandas as pd -import six from google.oauth2 import credentials as oauth2, service_account from gspread.client import Client as ClientV4 from gspread.exceptions import APIError @@ -51,7 +50,7 @@ def parse_df_col_names(df, include_index, index_size=1, flatten_sep=None): # handle multi-index headers if len(headers) > 0 and type(headers[0]) == tuple: - if isinstance(flatten_sep, six.string_types): + if isinstance(flatten_sep, str): headers = [ [ # Remove blank elements and join using sep @@ -238,7 +237,7 @@ def get_cell_as_tuple(cell): ): raise TypeError("{0} is not a valid cell tuple".format(cell)) return cell - elif isinstance(cell, six.string_types): + elif isinstance(cell, str): if not match("[a-zA-Z]+[0-9]+", cell): raise TypeError("{0} is not a valid address".format(cell)) return a1_to_rowcol(cell) @@ -454,7 +453,7 @@ def parse_permission(perm): def remove_keys(dct, keys=[]): """Remove keys from a dict.""" - return {key: val for key, val in six.iteritems(dct) if key not in keys} + return {key: val for key, val in dct.items() if key not in keys} def remove_keys_from_list(lst, keys=[]): diff --git a/pyproject.toml b/pyproject.toml index 98e46c5..77aeab1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,4 +7,4 @@ include_trailing_comma = true force_grid_wrap = 0 combine_as_imports = true line_length = 88 -known_third_party = ["Crypto", "betamax", "betamax_serializers", "google", "google_auth_oauthlib", "gspread", "numpy", "oauth2client", "pandas", "pytest", "requests", "setuptools", "six"] +known_third_party = ["Crypto", "betamax", "betamax_serializers", "google", "google_auth_oauthlib", "gspread", "numpy", "oauth2client", "pandas", "pytest", "requests", "setuptools"] diff --git a/requirements.txt b/requirements.txt index 1a2b1f9..5896180 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,5 @@ gspread<5.0.0 pandas>=0.20.0 decorator -six -pathlib2;python_version=="2.7" google-auth google-auth-oauthlib diff --git a/requirements_dev.txt b/requirements_dev.txt index e881f7c..efb58ef 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -9,7 +9,7 @@ flake8 pytest pre-commit isort -black;python_version>="3.6" +black pycryptodome betamax betamax_serializers diff --git a/setup.cfg b/setup.cfg index d32ce26..13d3bbe 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,14 +19,16 @@ max-complexity = 18 select = B,C,E,F,W,T4,B9 [tox:tox] -envlist = py27, py35, py36, py37, flake8 +envlist = py35, py36, py37, py38, py39, py310, flake8 [travis] -python = +python = + 3.10: py310 + 3.9: py39 + 3.8: py38 3.7: py37 3.6: py36 3.5: py35 - 2.7: py27 [testenv:flake8] basepython = python @@ -34,7 +36,7 @@ deps = flake8 commands = flake8 gspread_pandas [testenv] -setenv = +setenv = PYTHONPATH = {toxinidir} deps = -r requirements_dev.txt commands = python setup.py test diff --git a/setup.py b/setup.py index 8fb8bac..fa1e4c5 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,6 @@ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", ], keywords="gspread pandas google spreadsheets", diff --git a/tests/client_test.py b/tests/client_test.py index c77d5a3..5e0a85d 100644 --- a/tests/client_test.py +++ b/tests/client_test.py @@ -1,5 +1,4 @@ import pytest -import six from gspread_pandas import Client @@ -22,7 +21,7 @@ def test_directories(self): assert {"name", "id", "path"} == set(d.keys()) def test_email(self): - assert isinstance(self.client.auth.service_account_email, six.string_types) + assert isinstance(self.client.auth.service_account_email, str) def test_email_no_perm(self, betamax_client_bad_scope, capsys): betamax_client_bad_scope.email diff --git a/tests/conf_test.py b/tests/conf_test.py index 9bfd3c6..e9bfab7 100644 --- a/tests/conf_test.py +++ b/tests/conf_test.py @@ -1,4 +1,5 @@ import os +from pathlib import PosixPath, WindowsPath import pytest from google.oauth2.credentials import Credentials as OAuth2Credentials @@ -6,11 +7,6 @@ from gspread_pandas import conf, exceptions -try: - from pathlib import PosixPath, WindowsPath -except ImportError: - from pathlib2 import PosixPath, WindowsPath - def test_get_config_dir(): conf_dir = conf.get_config_dir() diff --git a/tests/conftest.py b/tests/conftest.py index 1265acf..8384a63 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,6 @@ import json import os +from pathlib import Path import pytest from betamax import Betamax @@ -10,12 +11,6 @@ from gspread_pandas import Client, Spread, conf from gspread_pandas.util import decode -# from betamax_json_body_serializer import JSONBodySerializer -try: - from pathlib import Path -except ImportError: - from pathlib2 import Path - pytest.RECORD = os.environ.get("GSPREAD_RECORD") is not None pytest.DUMMY_TOKEN = ""