Skip to main content

Some stupid badges:

https://badge.fury.io/py/insupportable.png https://travis-ci.org/Carreau/insupportable.png?branch=master

I am really annoyed, more and more, especially in old project to figure out what code is a war a workaround for old version of python, or another library.

This library should provide a simple way to warn you as early as possible when you can remove some legacy code, that deals with unsupported library version.

By default come pre-configured with Python 2/3 convenience function, but works with other libraries and more fine grained version numbering.

# warn you you have dead code if you
# drop Python2 support
from insupportable import support
if support('PY2'):
    print("You are on python 2")
else:
    print("You are on python 3")
# warn you you have dead code if you
# drop Python2 support
from insupportable import support
if support('PY3'):
    print("You are on python 3")
else:
    print("You are on python 2")

Set it up to drop Python2 support.

Quick and dirty way, modify global config, which is not recommended as it may affect other libraries that use this too, but super usefull.

support.config(PY2=False)

if support(PY2):
    print("You are on python 2")
else:
    print("You are on python 3")

warn the following:

mymodule/myfile.py:3: UserWarning: You are not supporting PY2 anymore
  if support(PY2):
mymodule/myfile.py:3: UserWarning: PY2 is the last supported feature of this group, you can simplifiy this logic.
  if support(PY2):

More involve way, create a config context that have effect only locally:

from insupportable import S

support = S(PY2=False).support

....

Advance configuration/custom features:

Example:

support.config(config=({
    'WindowsPhone':True,
    'Android'     :False,
    'iOS'         :False
   },))
if support('WindowsPhone'):
    print('Click on start menu')
else:
    print("Probably Android - but you don't support it anymore")
mymodule/myfile.py:1: UserWarning: WindowsPhone is the last supported feature of this group, you can simplifiy this logic.
  if support('WindowsPhone'):

TODO:

Write predicates and document like:

if workaround('tornado==2.2'):
    # do something special

The predicate would decide wether or not to yield depending on the version of tornado, and warn if min tornado is higher than 2.2

Deprecation decorator:

@deprecated_since('2.3.1',will_remove='3.0.0')
def my_api('something'):
    """deprecated fucntion that should
    warn user when function is **called**

    when module version is >= 3.0, the decorator should warn **developper** at **compile** time
    that code has to be removed.
    """

This case is more interesting than support() as there is 2 pass, the decoration of the function itsef, and the execution of the function. will_remove should infer next major I guess. Should we add option to deprecate after/at a date for some case like API.

@deprecate_after(date='2015/10/15'):
def marty_from_the_future(self):
    """
    Docs has some invalid ssl certificates ?
    """

Release files for insupportable 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for insupportable 0.1.2
File Interpreter ABI Platform
insupportable-0.1.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / insupportable-0.1.2-py2.py3-none-any.whl

Download URL insupportable-0.1.2-py2.py3-none-any.whl
Size 24.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4d6ec45227cc126fd78bdb57d65abd9ebd251072f9f6cd06079a1b179021dd4e
BLAKE2b-256 checksum
How to use checksums
ca56a0f90a485eaa65875001b335dcfeeeed15ca0aea9c38b9ac1f09c446ad10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page