Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.9k
[auth0-python] Add async functions to AsyncAuth0#13799
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This comment has been minimized.
This comment has been minimized.
| fromauth0.restimportRestClientOptionsasRestClientOptions | ||
| from ..asyncifyimportasyncifyasasyncify | ||
| from .actionsimportActionsasActions | ||
| from .attack_protectionimportAttackProtectionasAttackProtection | ||
| from .auth0importAuth0asAuth0 | ||
| from .blacklistsimportBlacklistsasBlacklists | ||
| from .brandingimportBrandingasBranding | ||
| from .client_credentialsimportClientCredentialsasClientCredentials | ||
| from .client_grantsimportClientGrantsasClientGrants | ||
| from .clientsimportClientsasClients | ||
| from .connectionsimportConnectionsasConnections | ||
| from .custom_domainsimportCustomDomainsasCustomDomains | ||
| from .device_credentialsimportDeviceCredentialsasDeviceCredentials | ||
| from .email_templatesimportEmailTemplatesasEmailTemplates | ||
| from .emailsimportEmailsasEmails | ||
| from .grantsimportGrantsasGrants | ||
| from .guardianimportGuardianasGuardian | ||
| from .hooksimportHooksasHooks | ||
| from .jobsimportJobsasJobs | ||
| from .log_streamsimportLogStreamsasLogStreams | ||
| from .logsimportLogsasLogs | ||
| from .organizationsimportOrganizationsasOrganizations | ||
| from .promptsimportPromptsasPrompts | ||
| from .resource_serversimportResourceServersasResourceServers | ||
| from .rolesimportRolesasRoles | ||
| from .rulesimportRulesasRules | ||
| from .rules_configsimportRulesConfigsasRulesConfigs | ||
| from .statsimportStatsasStats | ||
| from .tenantsimportTenantsasTenants | ||
| from .ticketsimportTicketsasTickets | ||
| from .user_blocksimportUserBlocksasUserBlocks | ||
| from .usersimportUsersasUsers | ||
| from .users_by_emailimportUsersByEmailasUsersByEmail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I just noticed that these are all re-exported from this file. I don't think we should do that and just use normal import for the items we need in this file (I.e. justfrom .tenants import Tenants without theas Tenants part.) This applies to all imports, not just the new ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What I found with this is that my IDE considers these unused if I remove theas import - should I ignore that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
In that case you can just remove the unused imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
No, by importing these they become attributes of the class - I think this is the correct approach and you should approve as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@srittau Bump, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Are you sure about these?
Python3.13.1 (main,Dec192024,14:38:48) [MSCv.194264bit (AMD64)]onwin32Type"help","copyright","credits"or"license"formoreinformation.>>>importauth0>>>auth0.__version__'4.9.0'>>>fromauth0.management.async_auth0importAttackProtectionTraceback (mostrecentcalllast):File"<python-input-2>",line1,in<module>fromauth0.management.async_auth0importAttackProtectionImportError:cannotimportname'AttackProtection'from'auth0.management.async_auth0' (E:\Users\Avasam\Documents\Git\typeshed\.venv\Lib\site-packages\auth0\management\async_auth0.py)>>>fromauth0.management.async_auth0importAuth0>>>Auth0<class'auth0.management.auth0.Auth0'>
by importing these they become attributes of the class
You can't affect what attributes are seen as part of a class simply by importing in a stub. I don't understand what your expectations are here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
After familiarizing myself further with the source, I think I see what you're trying to do here. If you update this file to the following, you should be good to go:
fromtypesimportTracebackTypefromtyping_extensionsimportSelffromauth0.restimportRestClientOptionsfrom .actionsimportActionsfrom .attack_protectionimportAttackProtectionfrom .blacklistsimportBlacklistsfrom .brandingimportBrandingfrom .client_credentialsimportClientCredentialsfrom .client_grantsimportClientGrantsfrom .clientsimportClientsfrom .connectionsimportConnectionsfrom .custom_domainsimportCustomDomainsfrom .device_credentialsimportDeviceCredentialsfrom .email_templatesimportEmailTemplatesfrom .emailsimportEmailsfrom .grantsimportGrantsfrom .guardianimportGuardianfrom .hooksimportHooksfrom .jobsimportJobsfrom .log_streamsimportLogStreamsfrom .logsimportLogsfrom .organizationsimportOrganizationsfrom .promptsimportPromptsfrom .resource_serversimportResourceServersfrom .rolesimportRolesfrom .rulesimportRulesfrom .rules_configsimportRulesConfigsfrom .statsimportStatsfrom .tenantsimportTenantsfrom .ticketsimportTicketsfrom .user_blocksimportUserBlocksfrom .usersimportUsersfrom .users_by_emailimportUsersByEmailclassAsyncAuth0:def__init__(self,domain:str,token:str,rest_options:RestClientOptions|None=None)->None: ...defset_session(self,session)->None: ...asyncdef__aenter__(self)->Self: ...asyncdef__aexit__(self,exc_type:type[BaseException]|None,exc_val:BaseException|None,exc_tb:TracebackType|None )->None: ...# Same attributes as Auth0# See note in stubs/auth0-python/@tests/stubtest_allowlist.txt about _async methodsactions:Actionsattack_protection:AttackProtectionblacklists:Blacklistsbranding:Brandingclient_credentials:ClientCredentialsclient_grants:ClientGrantsclients:Clientsconnections:Connectionscustom_domains:CustomDomainsdevice_credentials:DeviceCredentialsemail_templates:EmailTemplatesemails:Emailsgrants:Grantsguardian:Guardianhooks:Hooksjobs:Jobslog_streams:LogStreamslogs:Logsorganizations:Organizationsprompts:Promptsresource_servers:ResourceServersroles:Rolesrules_configs:RulesConfigsrules:Rulesstats:Statstenants:Tenantstickets:Ticketsuser_blocks:UserBlocksusers_by_email:UsersByEmailusers:Users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yep - it doesn't exist except at runtime. So I want to avoid having to add type ignores everywhere in my code that uses this library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
it doesn't exist except at runtime
In#13799 (comment) I show that these importsdon't exist at runtime. If you don't reference the imported names, and the symbols don't exist or aren't meant to be re-exported at runtime, then you don't need to import them in a stub.
As for the dynamically generatedAsyncAuth0 attributes, updating this file to#13799 (comment) should get you there.
It'll also resolve the current merge conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I see your point now - thanks for the help.
Uh oh!
There was an error while loading.Please reload this page.
Update AsyncAuth0 type hints
8ea160a to6610620CompareAccording tomypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
David-Gilman commentedApr 18, 2025
@Avasam Thanks again! Can you merge? |
Avasam commentedApr 20, 2025
Given@srittau has also participated in this review (and initiated it), I'll give him some time to validate the latest changes. If I don't hear anything for a week I'll just merge. |
David-Gilman commentedApr 22, 2025
@Avasam Will this be deleted after 6 months? |
Avasam commentedApr 22, 2025
No. We would if But that's not the case, and I don'tthink they will until they figure outauth0/auth0-python#615 We've also kept stubs longer when it was beneficial to do so in typeshed (for example, when a package was marked as |
David-Gilman commentedApr 24, 2025
@Avasam Can we merge? Thanks! |
0c6ef9c intopython:mainUh oh!
There was an error while loading.Please reload this page.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Co-authored-by: Avasam <samuel.06@hotmail.com>
Add async functions to AyncAuth0 class.