Remove unused compatability function by aucampia · Pull Request #1768 · RDFLib/rdflib (original) (raw)

This patch removes rdflib.compat.etree_register_namespace which was needed before xml.etree.register_namespace was added in python 3.2, however there is no code that uses it as is, so it serves no purpose anymore.

$ \rm -rf /var/tmp/rdflib-clean/
$ git clone --depth 1 --branch master git@github.com:RDFLib/rdflib.git /var/tmp/rdflib-clean/
Cloning into '/var/tmp/rdflib-clean'...
remote: Enumerating objects: 5392, done.
remote: Counting objects: 100% (5392/5392), done.
remote: Compressing objects: 100% (3837/3837), done.
remote: Total 5392 (delta 1213), reused 4996 (delta 1172), pack-reused 0
Receiving objects: 100% (5392/5392), 1.98 MiB | 1013.00 KiB/s, done.
Resolving deltas: 100% (1213/1213), done.
$ grep --exclude-dir={.tox,__pycache__,_build,build} -ri -e etree_register_namespace -e _namespace_map /var/tmp/rdflib-clean/
/var/tmp/rdflib-clean/rdflib/compat.py:    etree_register_namespace = etree.register_namespace
/var/tmp/rdflib-clean/rdflib/compat.py:    def etree_register_namespace(prefix, uri):
/var/tmp/rdflib-clean/rdflib/compat.py:        etreenative._namespace_map[uri] = prefix
$

I'm removing this primarily because it causes problems when running pytype on rdflib:

$ .venv/bin/pytype rdflib
...
File "/home/iwana/sw/d/github.com/iafork/rdflib.typing/rdflib/compat.py", line 28, in etree_register_namespace: No attribute '_namespace_map' on module 'xml.etree.ElementTree' [module-attr]
...