Skip to content

AssetPath doesn't implement parent #1433

Closed

Description

@mhsmith

It implements the documented Traversable interface, but it doesn't implement the undocumented SimplePath interface used by importlib.metadata. This causes an exception from this code in numpy/testing/_private/utils.py:

np_dist = importlib.metadata.distribution('numpy')
....
np_dist.locate_file('numpy')
  File "/data/data/com.chaquo.python.pkgtest3/files/chaquopy/AssetFinder/requirements/numpy/testing/_private/utils.py", line 86, in <module>
  File "stdlib/importlib/metadata/__init__.py", line 922, in locate_file
AttributeError: 'AssetPath' object has no attribute 'parent'

Review all Path properties and methods to see if there's anything else we should add at the same time.

Activity

  1. added this to the 18.0 milestone on Dec 10, 2025
  2. mhsmith commented on Jan 11, 2026

    @mhsmith
    MemberAuthor

    The following workaround is good enough for numpy. In the production fix, we should also make it possible to traverse out of the importer root and get a normal Path object.

    @property
    def parent(self):
        return type(self)(str(self).rpartition("/")[0])
    
    from java.android import importer
    importer.AssetPath.parent = parent
  3. mhsmith commented on Sep 20, 2026

    @mhsmith
    MemberAuthor

    #1471 suggests that dirname may be simpler than rpartition, but check first whether they're totally equivalent.

  4. pinned and unpinned a comment on Sep 20, 2026
  5. mhsmith commented on Oct 2, 2026

    @mhsmith
    MemberAuthor

    Review all Path properties and methods to see if there's anything else we should add at the same time.

    There are far too many of them, but in theory nothing should be depending on anything except for the methods of Traversable and SimplePath. In fact, we've had no reports of any missing members affecting anyone except via importlib.metadata, which is even more likely to respect the limited interface.

  6. added a commit that references this issue on Oct 11, 2026
    5e73d72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions