Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/zipp/compat/overlay.py: 92%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

12 statements  

1""" 

2Expose zipp.Path as .zipfile.Path. 

3 

4Includes everything else in ``zipfile`` to match future usage. Just 

5use: 

6 

7>>> from zipp.compat.overlay import zipfile 

8 

9in place of ``import zipfile``. 

10 

11Relative imports are supported too. 

12 

13>>> from zipp.compat.overlay.zipfile import ZipInfo 

14 

15The ``zipfile`` object added to ``sys.modules`` needs to be 

16hashable (#126). 

17 

18>>> _ = hash(sys.modules['zipp.compat.overlay.zipfile']) 

19""" 

20 

21import importlib 

22import sys 

23import types 

24 

25import zipp 

26 

27 

28class HashableNamespace(types.SimpleNamespace): 

29 def __hash__(self): 

30 return hash(tuple(vars(self))) 

31 

32 

33zipfile = HashableNamespace(**vars(importlib.import_module('zipfile'))) 

34zipfile.Path = zipp.Path 

35zipfile._path = zipp 

36 

37sys.modules[__name__ + '.zipfile'] = zipfile # type: ignore[assignment]