This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaraco
Recipients Anthony Sottile, jaraco, pablogsal
Date 2021-06-19.17:03:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624122231.26.0.551354325784.issue44459@roundup.psfhosted.org>
In-reply-to
Content
It seems that even on Python 3.9 or 3.10b2, the [DynamicRinohDistribution](https://github.com/brechtm/rinohtype/blob/e7f1c2c6066303d86cff4105be0829f512059be2/src/rinoh/resource.py#L132) would return `None` for the `name` property (despite the [attempt to return the empty string](https://github.com/brechtm/rinohtype/blob/e7f1c2c6066303d86cff4105be0829f512059be2/src/rinoh/resource.py#L135)). The Python object model doesn't allow overriding descriptor (@property) in a superclass with a static class property in the subclass.

I'm struggling to understand how the DynamicRinohDistribution works at all. I think I see. `importlib.metadata.Distribution`, while it declares a couple of abstract methods, doesn't actually declare itself an abstract base class, so someone can subclass it and get the degenerate behavior for the abstract methods. That's why a DynamicRinohDistribution.metadata gets `None` for `self.read_text` and then `email.message_from_string(None)` returns an empty `Message` object.

My instinct here is that the `Distribution.name` was always expected to return a string and the fact that it's returning `None` is a symptom of the subclass not implementing the abstract methods. To be sure, type annotations might have helped here (if the `name` property declared that the return type is `str`, then `None` would be an invalid return value).

The importlib distribution discovery mechanism was designed for other package distribution providers to make their distributions visible. It was not designed with the Rinoh use-case in mind (where a distribution already installed using the standard finders would present other "dynamic" distributions).

Given that Rinoh is using the distribution discovery mechanism in a way that it was not designed to support and is unlikely to be a widespread (or even repeated) use-case, I'm leaning toward a recommendation that the issue be fixed in Rinoh by defining a name property that returns text (and preferably something other than the empty string).
History
Date User Action Args
2021-06-19 17:03:51jaracosetrecipients: + jaraco, Anthony Sottile, pablogsal
2021-06-19 17:03:51jaracosetmessageid: <1624122231.26.0.551354325784.issue44459@roundup.psfhosted.org>
2021-06-19 17:03:51jaracolinkissue44459 messages
2021-06-19 17:03:51jaracocreate