-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
feat: Add get providers from entry points #469
base: main
Are you sure you want to change the base?
Conversation
@liiight Please have a look at this PR and let me know what you think. |
6653786
to
5228ee4
Compare
Could you elaborate on the use case for this please? If I understand correclty, this will allow a custom installation of notifiers with a specific provider as an entry point? If so, then:
|
@liiight Thank you for your reply. The recent modifications allow future providers to exist as plugins or extensions for notifiers. For example, we have created a new repository called setup(
name="xxx_provider",
package_dir={"": "."},
packages=find_packages("."),
entry_points={
"notifiers": [
"xxx_provider1= xxx_provider.main1",
"xxx_provider2= xxx_provider.main1",
],
},
) Then, by installing notifiers and our custom-written xxx_provider using pip, we can use notifiers through a unified interface like this: from notifiers import get_notifier
notifier = get_notifier('xxx_provider1')
notifier.notify(msgtype='text', api_key='1234', message='test') Another reason is that sometimes we encounter some niche or internal applications that want to use the features of notifiers. With the new updates, relevant developers can extend notifiers without modifying the source code. |
Oh, sort of like pytest enables its plugins to be loaded via the Can you please add an example for using this in the docs as well? |
@liiight Added a sample docs for that. |
82ca163
to
2a7d54b
Compare
for more information, see https://pre-commit.ci
b4b1510
to
e1607dd
Compare
… better validation and type hints
3d39284
to
4d46a17
Compare
for more information, see https://pre-commit.ci
@liiight |
This PR is add a new function to allow get providers from entry points.