Skip to content

Commit

Permalink
Drop support for python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
aiguofer committed Dec 29, 2021
1 parent b53822c commit 9e2cdcb
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 73 deletions.
23 changes: 0 additions & 23 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ Example

.. code:: python
from __future__ import print_function
import pandas as pd
from gspread_pandas import Spread, Client
Expand Down Expand Up @@ -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
<https://github.com/burnash/gspread/issues/223>`_
and `issue 354 <https://github.com/burnash/gspread/issues/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
-----------------

Expand Down
7 changes: 1 addition & 6 deletions gspread_pandas/client.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 3 additions & 11 deletions gspread_pandas/conf.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
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

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"
Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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:])
8 changes: 1 addition & 7 deletions gspread_pandas/spread.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions gspread_pandas/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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=[]):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
gspread<5.0.0
pandas>=0.20.0
decorator
six
pathlib2;python_version=="2.7"
google-auth
google-auth-oauthlib
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ flake8
pytest
pre-commit
isort
black;python_version>="3.6"
black
pycryptodome
betamax
betamax_serializers
Expand Down
10 changes: 6 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ 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
deps = flake8
commands = flake8 gspread_pandas

[testenv]
setenv =
setenv =
PYTHONPATH = {toxinidir}
deps = -r requirements_dev.txt
commands = python setup.py test
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions tests/client_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
import six

from gspread_pandas import Client

Expand All @@ -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
Expand Down
6 changes: 1 addition & 5 deletions tests/conf_test.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import os
from pathlib import PosixPath, WindowsPath

import pytest
from google.oauth2.credentials import Credentials as OAuth2Credentials
from google.oauth2.service_account import Credentials as ServiceAccountCredentials

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()
Expand Down
7 changes: 1 addition & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
from pathlib import Path

import pytest
from betamax import Betamax
Expand All @@ -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 = "<ACCESS_TOKEN>"

Expand Down

0 comments on commit 9e2cdcb

Please sign in to comment.