Skip to content

Commit

Permalink
update package setup and CI, remove some old deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
guruofgentoo committed Oct 26, 2022
1 parent b7c08f2 commit e52cd73
Show file tree
Hide file tree
Showing 39 changed files with 94 additions and 391 deletions.
20 changes: 20 additions & 0 deletions .circleci/pytest.ini
@@ -0,0 +1,20 @@
# This file's purpose is to keep a developer's local pytest.ini from interfering with tox
# tests as well as control turning warnings into errors.
[pytest]
junit_family=xunit2
filterwarnings =
# Any errors not noted here should cause pytest to throw an error. It seems like this should be
# last in the list, but warnings that match multiple lines will apply the last line matched.
error

# Example warning filters

# We support openpyxl, but also maintain some xlrd support
ignore:xlrd is no longer maintained

# DeprecationWarning should only be visible when testing with older libraries (i.e. "lowest"
# tests") -- https://github.com/level12/keg/issues/164
ignore:.*soft_unicode

# Flask version incompatability warning - https://github.com/level12/keg/issues/163
ignore:The 'script_info' argument is deprecated
2 changes: 0 additions & 2 deletions blazeutils/__init__.py
@@ -1,14 +1,12 @@
# flake8: noqa

from __future__ import absolute_import
from os import path as osp

## legacy imports, future imports should use the full import path
from blazeutils.datastructures import DumbObject, OrderedProperties, OrderedDict, \
HtmlAttributeHolder
from blazeutils.dates import safe_strftime
from blazeutils.decorators import decorator, curry
from blazeutils.error_handling import tb_depth_in, traceback_depth
from blazeutils.filesystem import randfile
from blazeutils.functional import posargs_limiter
from blazeutils.helpers import tolist, toset, grouper, is_empty, is_iterable, \
Expand Down
3 changes: 0 additions & 3 deletions blazeutils/config.py
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import copy

from blazeutils.datastructures import OrderedProperties, OrderedDict
Expand Down
8 changes: 1 addition & 7 deletions blazeutils/containers.py
@@ -1,9 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import six


class LazyDict(dict):
def __init__(self, *args, **kwargs):
self._ld_initialized = kwargs.pop('_ld_initialize', True)
Expand Down Expand Up @@ -35,7 +29,7 @@ def __delattr__(self, name):
del self[name]


class _Attribute(six.text_type):
class _Attribute(str):
def __add__(self, other):
return _Attribute('{0} {1}'.format(self, other).lstrip(' '))

Expand Down
3 changes: 0 additions & 3 deletions blazeutils/datastructures.py
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

from blazeutils.containers import LazyDict # noqa
from blazeutils.sentinels import NotGiven

Expand Down
3 changes: 0 additions & 3 deletions blazeutils/dates.py
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import datetime as dt


Expand Down
11 changes: 4 additions & 7 deletions blazeutils/decorators.py
@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import functools
from functools import partial
import inspect
Expand All @@ -13,8 +9,6 @@
import warnings

import wrapt
import six
from six.moves import range, map

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -242,14 +236,17 @@ def wrapper(wrapped, instance, args, kwargs):
exc_info = sys.exc_info()
error_msg = 'exc_mailer() caught an exception, email will be sent.'
logger.exception(error_msg)
reraise = False
if print_to_stderr:
print(error_msg + ' ' + str(e), file=sys.stderr)
try:
send_mail_func(body)
except Exception:
logger.exception('exc_mailer(): send_mail_func() threw an exception, '
'logging it & then re-raising original exception')
six.reraise(exc_info[0], exc_info[1], exc_info[2])
reraise = True
if reraise:
raise
finally:
# delete the traceback so we don't have garbage collection issues.
# see warning at: http://docs.python.org/library/sys.html#sys.exc_info
Expand Down
31 changes: 0 additions & 31 deletions blazeutils/error_handling.py
@@ -1,35 +1,4 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import re
import sys

from blazeutils.helpers import tolist
from blazeutils.decorators import deprecate


def tb_depth_in(depths):
"""
looks at the current traceback to see if the depth of the traceback
matches any number in the depths list. If a match is found, returns
True, else False.
"""
depths = tolist(depths)
if traceback_depth() in depths:
return True
return False
traceback_depth_in = tb_depth_in # noqa: E305


@deprecate('tb_depth_in(), traceback_depth() deprecated, its a bad idea')
def traceback_depth(tb=None):
if tb is None:
_, _, tb = sys.exc_info()
depth = 0
while tb.tb_next is not None:
depth += 1
tb = tb.tb_next
return depth


def raise_unexpected_import_error(our_import, exc):
Expand Down
3 changes: 0 additions & 3 deletions blazeutils/filesystem.py
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

from os import path
from blazeutils.strings import randchars

Expand Down
9 changes: 2 additions & 7 deletions blazeutils/functional.py
@@ -1,12 +1,7 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import functools
import itertools
import inspect

import six

from blazeutils import curry


Expand Down Expand Up @@ -77,7 +72,7 @@ def first_where(pred, iterable, default=None):
:param default: is the default value to use if the predicate matches none of the elements.
"""
return next(six.moves.filter(pred, iterable), default)
return next(filter(pred, iterable), default)


def identity(x):
Expand Down Expand Up @@ -119,7 +114,7 @@ def unzip(iterable):
left, right = unzip(two_columned_list) or ([], [])
"""
return list(map(list, list(six.moves.zip(*iterable))))
return list(map(list, list(zip(*iterable))))


def flatten(iterable):
Expand Down
6 changes: 1 addition & 5 deletions blazeutils/helpers.py
@@ -1,10 +1,6 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import csv
import difflib
from pprint import PrettyPrinter
import six
import time

from blazeutils.datastructures import OrderedDict
Expand Down Expand Up @@ -63,7 +59,7 @@ def pformat(stuff, indent=4):


def is_iterable(possible_iterable):
if isinstance(possible_iterable, six.string_types):
if isinstance(possible_iterable, str):
return False
try:
iter(possible_iterable)
Expand Down
4 changes: 1 addition & 3 deletions blazeutils/importing.py
Expand Up @@ -3,8 +3,6 @@
import site
from os import path

import six


def prependsitedir(projdir, *args):
"""
Expand Down Expand Up @@ -81,7 +79,7 @@ def find_path_package(thepath):
pname = find_path_package_name(thepath)
if not pname:
return None
fromlist = b'' if six.PY2 else ''
fromlist = ''
return __import__(pname, globals(), locals(), [fromlist])


Expand Down
6 changes: 0 additions & 6 deletions blazeutils/numbers.py
@@ -1,11 +1,5 @@
from __future__ import absolute_import
from __future__ import unicode_literals

from decimal import Decimal

from six.moves import map
from six.moves import range


# from http://docs.python.org/library/decimal.html#recipes
def moneyfmt(value, places=2, curr='', sep=',', dp='.',
Expand Down
9 changes: 3 additions & 6 deletions blazeutils/rst.py
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

try:
import docutils
from docutils.core import publish_programmatically, Publisher
Expand Down Expand Up @@ -82,7 +79,7 @@ def docinfo2dict(doctree):
pub = rst2pub(rst_string)
print docinfo2dict(pub.document)
"""
nodes = doctree.traverse(docutils.nodes.docinfo)
nodes = list(doctree.findall(docutils.nodes.docinfo))
md = {}
if not nodes:
return md
Expand Down Expand Up @@ -138,7 +135,7 @@ def create_toc(doctree, depth=9223372036854775807, writer_name='html',
# want to be able to give just the sub-sections
startnode = None
if exclude_first_section:
nodes = doctree.traverse(docutils.nodes.section)
nodes = list(doctree.findall(docutils.nodes.section))
if nodes:
startnode = nodes[0]

Expand Down Expand Up @@ -196,7 +193,7 @@ def prefix_refids(document, href_prefix):
# page. In that case, an href_prefix can be sent in. The only downfall
# to doing this way is that the writer automatically sets an "external"
# class on a reference with 'refuri' instead of 'refid'.
nodes = document.traverse(docutils.nodes.reference)
nodes = document.findall(docutils.nodes.reference)
for node in nodes:
node['refuri'] = '{0}#{1}'.format(href_prefix, node['refid'])
del node['refid']
3 changes: 0 additions & 3 deletions blazeutils/sentinels.py
@@ -1,6 +1,3 @@
from __future__ import unicode_literals


class NotGivenBase(object):
""" an empty sentinel object that acts like None """

Expand Down
3 changes: 0 additions & 3 deletions blazeutils/spreadsheets.py
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import datetime as dt
from decimal import Decimal
from io import BytesIO
Expand Down
8 changes: 1 addition & 7 deletions blazeutils/strings.py
@@ -1,14 +1,8 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import hashlib
import random
import re
import time

import six
from six.moves import range


class StringIndenter(object):

Expand Down Expand Up @@ -133,7 +127,7 @@ def randnumerics(n=12):


def randhash():
random_str = six.text_type(random.random()) + six.text_type(time.perf_counter())
random_str = str(random.random()) + str(time.perf_counter())
return hashlib.md5(random_str.encode('utf-8')).hexdigest()


Expand Down

0 comments on commit e52cd73

Please sign in to comment.