Have term .toPython() methods pass with mypy-strict-reviewed consumers
Have term .toPython() methods pass with mypy-strict-reviewed consumers

This patch is believed to be part of what would be necessary to resolve
Issue 1447.

This patch addresses type errors raised by `mypy` pertaining to use of
untyped methods within typed contexts.  These signatures are sufficient
to pass a test application (coming in a following patch) that exercises:

* creation of a graph;
* use of `Graph.add()` to supply triples containing `URIRef`, `BNode`,
  and `Literal` objects;
* use of `Graph.triples()`;
* use of `Graph.query()` with a string argument;
* use of `Graph.query()` with a `Query` argument;
* use of `Graph.query()` to return query results with different
  bound-variable lengths (i.e. different tuple lengths); and
* use of several `.toPython()` methods, including `Literal.toPython()`.

To address issues with the various `Node` subclasses appearing to be
untyped on initialization, this patch introduces `__init__` methods to
satisfy `mypy` needing a type signature.  To support any future
initialization logic, `super()` is used to support the Method Resolution
Order chain.  The alternative approach of trying to assign return types
to `__new__` didn't seem to work for two reasons that would require more
significant design revision:

* `BNode.__new__()` returns an `Identifier`, and `mypy` complained that
  this is an incompatible return type.  Attempting `typing.cast()`
  didn't seem to resolve this problem.
* `Literal.__new__()` was raising this `mypy --strict` error:
  ```
  "Literal" has no attribute "_value"; maybe "value"?
  ```
  I can't think of a practice aside from exposing `_value` as a slot
  that would convince `mypy` that the field exists.

Hence, the classes under `rdflib/term.py` got `__init__()` methods.

References:
* https://github.com/RDFLib/rdflib/issues/1447
* https://stackoverflow.com/a/33533514 describes PEPs 484 and 563
  relative to this patch.

Signed-off-by: Alex Nelson <d5aca716d6ed55a86fa350cb5231ca56b21085ca@nist.gov>

RDFLib/rdflib,RDFLib/rdflib,RDFLib/rdflib,RDFLib/rdflib