Skip to content

Commit 351bcf1

Browse files
nisimondjuledwar
authored andcommitted
Move the warnings.formatwarning call into the CLI
This setting is global, so it is bad form for libraries to alter it; the top-level application should be responsible for such things. Fixes: Issue #56
1 parent 341e327 commit 351bcf1

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

soufi/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import shutil
88
import sys
9+
import warnings
910

1011
from soufi import exceptions, finder
1112

@@ -15,6 +16,7 @@
1516
except ImportError:
1617
sys.exit("CLI support not installed; please install soufi[cli]")
1718

19+
warnings.formatwarning = lambda msg, *x, **y: f'WARNING: {msg}\n'
1820

1921
# Configure a small-ish in-memory LRU cache to speed up operations
2022
LRU_CACHE = pylru.lrucache(size=512)

soufi/finders/alpine.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
from soufi import exceptions, finder
1717

18-
warnings.formatwarning = lambda msg, *x, **y: f'WARNING: {msg}\n'
19-
2018
# Shell snippet that will source an APKBUILD and spit out the vars that we
2119
# need. CARCH is set to work around a bug in 3.12.0 scripts. CTARGET_ARCH
2220
# is needed for more complex scripts like `community/go`.

soufi/finders/yum.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
from soufi import exceptions, finder
2020

21-
warnings.formatwarning = lambda msg, *x, **y: f"WARNING: {msg}\n"
22-
2321

2422
class YumFinder(finder.SourceFinder, metaclass=abc.ABCMeta):
2523
"""An abstract base class for making Yum-based finders.

0 commit comments

Comments
 (0)