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

Type error on init_app #71

Closed
nchietala opened this issue Oct 6, 2023 · 11 comments · Fixed by #72
Closed

Type error on init_app #71

nchietala opened this issue Oct 6, 2023 · 11 comments · Fixed by #72

Comments

@nchietala
Copy link

nchietala commented Oct 6, 2023

File ".../site-packages/flask_multipass/util.py", line 146, in resolve_provider_type
entry_points = importlib_entry_points(group=base._entry_point, name=type_)

TypeError: entry_points() for an unexpected keyword argument 'group'

I see this error and version 0.5 dies while loading.
It's trying to call importlib.metadata.entrypoints but that doesn't have a group argument.

@ThiefMaster
Copy link
Member

On which Python version does that happen?

@nchietala
Copy link
Author

nchietala commented Oct 6, 2023

python 3.10.3
flask-multipass 0.5
flask 2.2.5
importlib-metadata 6.8.0

@nchietala
Copy link
Author

Correction: 3.9.5, the problem doesn't seem to occur on the 3.10 environment.

@ThiefMaster
Copy link
Member

OK that makes more sense, because there were some significant changes to importlib.metadata between 3.9 and 3.10.

@nchietala
Copy link
Author

I'm thinking something like

if sys.version_info < (3, 10):
    entry_points= [ep for ep in entry_points().get(base._entry_point, []) if ep.name == type_]
else:
    entry_points= entry_points(group=base._entry_point, name=type_)

@ThiefMaster
Copy link
Member

first of all i need to get the tests to fail ;) maybe i'm mocking too much there...

@ThiefMaster
Copy link
Member

ok, found a minimal repro that makes use of the real entrypoints instead of mocked ones

def test_load_providers():
    app = Flask('test')
    app.config['SECRET_KEY'] = 'testing'
    app.config['MULTIPASS_AUTH_PROVIDERS'] = {'test': {'type': 'static'}}
    app.config['MULTIPASS_IDENTITY_PROVIDERS'] = {'test': {'type': 'static'}}
    app.config['MULTIPASS_PROVIDER_MAP'] = {'test': 'test'}
    Multipass(app)

@ThiefMaster
Copy link
Member

OK please check the PR; i think that should be fine on all supported python versions now...

@nchietala
Copy link
Author

That seems to be behaving now, thank you.

@ThiefMaster
Copy link
Member

v0.5.1 is now released

@ThiefMaster
Copy link
Member

While updating another extension I realized that it's probably much better/easier/cleaner to simply add importlib-metadata as a dependency and using that instead of the stdlib version. No need for version-specific code that way.

I might change this in a point release in order to be less exposed to future changes in importlib.metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants