-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
config
submodule and ALLOW_DUPLICATES
global config variable
- Loading branch information
Showing
2 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
''' | ||
Contains globally applicable configuration variables. | ||
''' | ||
from functools import wraps | ||
from typing import Callable | ||
|
||
|
||
def default_params(func: Callable): | ||
''' | ||
This decorator sets default kwarg values using global configuration variables. | ||
''' | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
global ALLOW_DUPLICATES | ||
kwargs.setdefault('allow_duplicates', ALLOW_DUPLICATES) | ||
return func(*args, **kwargs) | ||
return wrapper | ||
|
||
|
||
ALLOW_DUPLICATES = False | ||
''' | ||
Global configuration variable that sets the default value for `allow_duplicates` kwargs. | ||
''' |