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 annotation error in pycountry.countries.search_fuzzy? #211

Open
alichaudry opened this issue Feb 8, 2024 · 0 comments
Open

Type annotation error in pycountry.countries.search_fuzzy? #211

alichaudry opened this issue Feb 8, 2024 · 0 comments

Comments

@alichaudry
Copy link

I'm not sure if I'm doing something wrong, but the following code is throwing a mypy error:

    matches = pycountry.countries.search_fuzzy(country_name)
    if matches:
        return matches[0].alpha_2

The mypy error is:

"type[ExistingCountries]" has no attribute "alpha_2" Mypy[attr-defined]

But if I check in the interpreter, I can see it is indeed an attribute there:

In [19]: type(country)
Out[19]: pycountry.db.Country

In [20]: country.alpha_2
Out[20]: 'GB'

Perhaps an issue in the typing that was added recently?

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

No branches or pull requests

1 participant