Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setuptools plugin solution for variables #1121

Closed
wants to merge 15 commits into from
5 changes: 4 additions & 1 deletion dedupe/datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ def typify_variables(
variable_definitions: Iterable[VariableDefinition],
) -> tuple[list[FieldVariable], list[Variable]]:

variable_types = {variable.type: variable for variable in dedupe.variables.__all__}
variable_types = {}
for variablename in dedupe.variables.__all__:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you copied this from my PR, I'm not positive that all is actually the correct solution, perhaps I'm abusing it and it actually is intended for something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's intended use is to control the behavior of "import *" but i think this works fine.

variable = getattr(dedupe.variables, variablename)
variable_types[variable.type] = variable

plugin_vars = load_setuptools_entrypoints("dedupevariables")
for var in plugin_vars:
Expand Down
22 changes: 11 additions & 11 deletions dedupe/variables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
from dedupe.variables.string import ShortStringType, StringType, TextType

__all__ = [
CustomType,
CategoricalType,
ExactType,
ExistsType,
InteractionType,
LatLongType,
PriceType,
SetType,
ShortStringType,
StringType,
TextType,
"CustomType",
"CategoricalType",
"ExactType",
"ExistsType",
"InteractionType",
"LatLongType",
"PriceType",
"SetType",
"ShortStringType",
"StringType",
"TextType",
]