Skip to content

Commit

Permalink
Bump backoff to be compatible with newer python versions (#165)
Browse files Browse the repository at this point in the history
* bump backoff for pyton 3.11 compatibility

* update pip version

* try new circleci yml

* remove 'make'

* make pylint happy

* make pylint happy

* make pylint happy again

* backoff version is a breaking change for old python versions

* Changelog update
  • Loading branch information
leslievandemark authored Jan 16, 2024
1 parent 2c053f4 commit 0d0ff1e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 27 deletions.
35 changes: 22 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
version: 2
version: 2.1

workflows:
build:
jobs:
- build:
context:
- circleci-user

jobs:
build:
docker:
- image: ubuntu:16.04
- image: 218546966473.dkr.ecr.us-east-1.amazonaws.com/sources-python:1.1.0
steps:
- checkout
- run:
name: 'Install python 3.5.2'
command: |
apt update
apt install --yes python3 python3-pip python3-venv
- run:
name: 'Setup virtualenv'
command: |
mkdir -p ~/.virtualenvs
pyenv global 3.11.7
python3 -m venv ~/.virtualenvs/singer-python
source ~/.virtualenvs/singer-python/bin/activate
pip install -U 'pip<19.2' 'setuptools<51.0.0'
make install
pip install -U 'pip==20.3.4' 'setuptools<51.0.0'
pip install .[dev]
- run:
name: 'Pylint'
command: |
source ~/.virtualenvs/singer-python/bin/activate
pip install pylint
pylint singer --extension-pkg-whitelist=ciso8601 -d missing-docstring,broad-exception-raised,broad-exception-caught,bare-except,too-many-return-statements,too-many-branches,too-many-arguments,no-else-return,too-few-public-methods,fixme,protected-access,consider-using-f-string
- run:
name: 'Run tests'
name: 'Run Tests'
command: |
# Need to re-activate the virtualenv
source ~/.virtualenvs/singer-python/bin/activate
make test
pip install nose2
nose2 -v -s tests
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 6.0.0
* Bump backoff version to 2.2.1. This version drops support for python 3.5, but adds it for 3.1o [#165](https://github.com/singer-io/singer-python/pull/165)

## 5.13.0
* Add support for dev mode argument parsing [#158](https://github.com/singer-io/singer-python/pull/158)

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import subprocess

setup(name="singer-python",
version='5.13.0',
version='6.0.0',
description="Singer.io utility library",
author="Stitch",
classifiers=['Programming Language :: Python :: 3 :: Only'],
Expand All @@ -14,7 +14,7 @@
'jsonschema==2.6.0',
'simplejson==3.11.1',
'python-dateutil>=2.6.0',
'backoff==1.8.0',
'backoff==2.2.1',
'ciso8601',
],
extras_require={
Expand Down
2 changes: 1 addition & 1 deletion singer/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __eq__(self, other):

@classmethod
def load(cls, filename):
with open(filename) as fp: # pylint: disable=invalid-name
with open(filename, encoding="utf-8") as fp:
return Catalog.from_dict(json.load(fp))

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion singer/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, message):
The first line is the error's class name. The subsequent lines are
the message that class was created with.
"""
super().__init__('{}\n{}'.format(self.__class__.__name__, message))
super().__init__(f"{self.__class__.__name__}\n{message}")


class SingerConfigurationError(SingerError):
Expand Down
8 changes: 4 additions & 4 deletions singer/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
class Message():
'''Base class for messages.'''

def asdict(self): # pylint: disable=no-self-use
def asdict(self):
raise Exception('Not implemented')

def __eq__(self, other):
return isinstance(other, Message) and self.asdict() == other.asdict()

def __repr__(self):
pairs = ["{}={}".format(k, v) for k, v in self.asdict().items()]
pairs = [f"{k}={v}" for k, v in self.asdict().items()]
attrstr = ", ".join(pairs)
return "{}({})".format(self.__class__.__name__, attrstr)
return f"{self.__class__.__name__}({attrstr})"

def __str__(self):
return str(self.asdict())
Expand Down Expand Up @@ -169,7 +169,7 @@ def asdict(self):

def _required_key(msg, k):
if k not in msg:
raise Exception("Message is missing required key '{}': {}".format(k, msg))
raise Exception(f"Message is missing required key '{k}': {msg}")

return msg[k]

Expand Down
8 changes: 4 additions & 4 deletions singer/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ def tostr(self):
path = ".".join(map(str, self.path))
if self.schema:
if self.logging_level >= logging.INFO:
msg = "data does not match {}".format(self.schema)
msg = f"data does not match {self.schema}"
else:
msg = "does not match {}".format(self.schema)
msg = f"does not match {self.schema}"
else:
msg = "not in schema"

if self.logging_level >= logging.INFO:
output = "{}: {}".format(path, msg)
output = f"{path}: {msg}"
else:
output = "{}: {} {}".format(path, self.data, msg)
output = f"{path}: {self.data} {msg}"
return output


Expand Down
4 changes: 2 additions & 2 deletions singer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def chunk(array, num):


def load_json(path):
with open(path) as fil:
with open(path, encoding="utf-8") as fil:
return json.load(fil)


Expand Down Expand Up @@ -193,7 +193,7 @@ def parse_args(required_config_keys):
def check_config(config, required_keys):
missing_keys = [key for key in required_keys if key not in config]
if missing_keys:
raise Exception("Config is missing required keys: {}".format(missing_keys))
raise Exception(f"Config is missing required keys: {missing_keys}")


def backoff(exceptions, giveup):
Expand Down

0 comments on commit 0d0ff1e

Please sign in to comment.