Skip to content

Can Country.code be None in v8.x? #481

@jodal

Description

@jodal

After the addition of fields.pyi in d6968e3, Country.code can now be None.

Looking at the actual implementation in Country.__init__(), which accepts code: str and then does:

self.code = self.countries.alpha2(code) or code

...it doesn't look like Country.code can actually ever be None?

Reason I'm asking is that we're running into ~20 typing warnings in our codebase when upgrading to django-countries 8.x because we've been under the belief that if we have a Country, we always have a code too.

Is this assumption no longer correct, or is the new Country.code type too wide?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions