Public bug reported:

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 = reader.city('8.8.8.8')
country = response.country
print(type(country), country.iso_code)

produces the following output:

$ python3 test.py
<class 'geoip2.records.Country'> US
$ pylint test.py
************* Module test
test.py:5: [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__
'Country'

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 https://github.com/PyCQA/pylint/issues/4911.

** Affects: python-geoip2 (Ubuntu)
     Importance: Undecided
         Status: New

** Description changed:

  Ubuntu 20.04.3 LTS
  python3-geoip2: 2.9.0+dfsg1-2
  
  The following code:
- ```python3
+ 
  from geoip2.database import Reader
  reader = Reader('/var/lib/GeoIP/GeoLite2-City.mmdb')
  response = reader.city('8.8.8.8')
  country = response.country
  print(type(country), country.iso_code)
- ```
+ 
  produces the following output:
- ```python3
+ 
  $ python3 test.py
  <class 'geoip2.records.Country'> US
  $ pylint test.py
  ************* Module test
  test.py:5: [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) 
+ 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
+ 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) 
+ 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__
  'Country'
- ```
- Another potential reason may be confusion between `geoip2.records.Country` 
and `geoip2.models.Country` that has no such field.
+ 
+ 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 https://github.com/PyCQA/pylint/issues/4911.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1941625

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-geoip2/+bug/1941625/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to