titipata / pubmed_parser

:clipboard: A Python Parser for PubMed Open-Access XML Subset and MEDLINE XML Dataset
http://titipata.github.io/pubmed_parser/
MIT License
564 stars 164 forks source link

SyntaxWarning raised during import #75

Closed tleonardi closed 4 years ago

tleonardi commented 4 years ago

Importing pubmed_parser in python3 raises the following warnings:

Python 3.8.1 (default, Jan  8 2020, 23:09:20) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pubmed_parser as p
/home/tleonardi/nobackup/pubmed_parse_tleonardi/pubmed_parser/pubmed_web_parser.py:147: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  pmc_text = [c for c in citation.split('/') if c is not ''][-1]
/home/tleonardi/nobackup/pubmed_parse_tleonardi/pubmed_parser/pubmed_web_parser.py:246: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if id_type is 'PMC':
/home/tleonardi/nobackup/pubmed_parse_tleonardi/pubmed_parser/pubmed_web_parser.py:249: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif id_type is 'PMID':
>>> 

This is due to a documented change in Python3.8.

The compiler now produces a SyntaxWarning when identity checks (is and is not)
are used with certain types of literals (e.g. strings, numbers). These can often work 
by accident in CPython, but are not guaranteed by the language spec. The warning
advises users to use equality tests (== and !=) instead. (Contributed by Serhiy
Storchaka in bpo-34850.)
titipata commented 4 years ago

@tleonardi, ah, thanks for the catch! I will check through the repository to see if there are more errors similar to this issue before closing it.

titipata commented 4 years ago

I checked this issue and it seems like this should be all fixed after #78. I will close this issue for now. Thanks @tleonardi for the contribution!