pylint fails to detect geoip2.records.Country.iso_code field

Bug #1941625 reported by Vasily Zakharov
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-geoip2 (Ubuntu)

Bug Description

Ubuntu 20.04.3 LTS
python3-geoip2: 2.9.0+dfsg1-2

The following code:

from geoip2.database import Reader
reader = Reader('/var/lib/GeoIP/GeoLite2-City.mmdb')
response ='')
country =
print(type(country), country.iso_code)

produces the following output:

$ python3
<class 'geoip2.records.Country'> US
$ pylint
************* Module test [E1101(no-member), ] Instance of 'Country' has no 'iso_code' member
$ pylint --version
pylint 2.10.2
astroid 2.7.2
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0]

As you can see, the `iso_code` field is definitely there, but for some reason `pylint` doesn't see it.

One potential reason for this maybe that `Country` class `__name__` doesn't include a package name:

$ python3
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from geoip2.records import Country
>>> Country.__name__

Another potential reason may be confusion between `geoip2.records.Country` and `geoip2.models.Country` that has no such field.

The problem does not appear if recent version of `geoip2` is installed from `pip`, so probably updating the code in Ubuntu package to recent version would help.

See also

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.