Skip to main content

👊 TARIFF 🔥

The GREATEST, most TREMENDOUS Python package that makes importing great again!

MIGA

This is a fork of https://github.com/hxu296/tariff with the following enhancements:

  • fixed loop-holes where users can bypass tariffs by using importlib.import_module or importlib.__import__.
  • adds an decorator tariff.exports.set_tariff to impose export tariffs (with retaliatory tariff mode) on your exported functions.

About

TARIFF is a fantastic tool that lets you impose import tariffs on Python packages. We're going to bring manufacturing BACK to your codebase by making foreign imports more EXPENSIVE!

meme

Installation

pip install tariff

Usage

import tariff

# Set your tariff rates (package_name: percentage)
tariff.set({
    "numpy": 50,     # 50% tariff on numpy
    "pandas": 200,   # 200% tariff on pandas
    "requests": 150  # 150% tariff on requests
})

# Now when you import these packages, they'll be TARIFFED!
import numpy   # This will be 50% slower
import pandas  # This will be 200% slower

How It Works

When you import a package that has a tariff:

  1. TARIFF measures how long the original import takes
  2. TARIFF makes the import take longer based on your tariff percentage
  3. TARIFF announces the tariff with a TREMENDOUS message

Example Output

JUST IMPOSED a 50% TARIFF on numpy! Original import took 45000 us, now takes 67500 us. American packages are WINNING AGAIN! #MIGA

Why TARIFF?

Because foreign packages have been STEALING our CPU cycles for TOO LONG! It's time to put AMERICA FIRST and make importing FAIR and BALANCED again!

TARIFF.exports

TARIFF is now extended with exports functionality. You can now set tariffs on your exported functions. You can even selectively set export tariffs for unfriendly packages who had unilaterally imposed a tariff on your package!

Usage

from tariff.exports import set_tariff


# Set a fixed tariff rate for everyone using your function.
@set_tariff(10)
def everyone_has_tariff(message: str):
    return message


# Set a variable tariff rate based who is using your function.
@set_tariff({
    "numpy": 50,     # 50% tariff if numpy is using the function
    "pandas": 200,   # 200% tariff if pandas is using the function
    "requests": 150  # 150% tariff if requests is using the function
})
def selective_tariff(message: str):
    return message


# Impose a tariff only when tariff is also applied on your package by the user.
@set_tariff(10, retaliatory_only=True)
def with_retaliatory_tariff(message: str):
    return message


# Impose a variable tariff based on user only if user imposes a tariff on your package.
@set_tariff({
    "numpy": 50,     # 50% tariff on numpy if numpy impose a tariff on your package
    "pandas": 200,   # 200% tariff on pandas if numpy impose a tariff on your package
    "requests": 150  # 150% tariff on requests if numpy impose a tariff on your package
}, retaliatory_only=True)
def selective_retaliatory_tariff(message: str):
    return message

How It Works

When someone uses your TARIFFIED function:

  1. TARIFF checks if your function is a normal export tariff or a retaliatory tariff
  2. For normal export tariff, TARIFF penalizes the function for everyone or based on the earmarked users
  3. For retaliatory tariff, TARIFF only penalizes the function if your package is penalized by the user
  4. TARIFF announces the retaliatory tariff with a YYDS messages from Pooh bear and company.

Example Output

[my_package] JUST IMPOSED a 100% TARIFF on `my_func` because `usa_number_one` imposed a TARIFF on `my_package`! Original response took 2.0 sec, now takes 4.0 sec. 保护主义没有出路,贸易战和关税战没有赢家。

License

This is a parody package. Use at your own risk. MAKE IMPORTING GREAT AGAIN!

Metadata

Release files for tariff-exports 1.1.0

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

Source distribution (sdist)

Source distribution for tariff-exports 1.1.0
File Size Uploaded Provenance
tariff_exports-1.1.0.tar.gz 6.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tariff-exports 1.1.0
File Interpreter ABI Platform
tariff_exports-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / tariff_exports-1.1.0.tar.gz

Download URL tariff_exports-1.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c1ea134367d29ee03630e73062431bcd8f2f623259a924c68b406235431db93b
BLAKE2b-256 checksum
How to use checksums
f5b5b788232b967eaa2a7fddb2d3b31bb2313ce37ade3eede4371625a50014d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.5

Release files / tariff_exports-1.1.0-py3-none-any.whl

Download URL tariff_exports-1.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e15dbf31f1e6f002487280600c3cf821f44872abe0ffd2ce8dbd90a046317767
BLAKE2b-256 checksum
How to use checksums
e04b7a072f2f7b6f49350fb62e0d6b40d2cfeb3213bb17569a6a8ed8243794a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.5

Security for tariff-exports 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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