Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-64020: Deprecate pydoc.ispackage() #20908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ Deprecated
coroutine.
(Contributed by Irit Katriel in :gh:`81137`.)

* Deprecate undocumented :func:`!pydoc.ispackage` function.
(Contributed by Zackery Spytz in :gh:`64020`.)


Pending Removal in Python 3.14
------------------------------
Expand Down
2 changes: 2 additions & 0 deletions Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ def sort_attributes(attrs, object):

def ispackage(path):
"""Guess whether a path refers to a package directory."""
warnings.warn('The pydoc.ispackage() function is deprecated',
DeprecationWarning, stacklevel=2)
if os.path.isdir(path):
for ext in ('.py', '.pyc'):
if os.path.isfile(os.path.join(path, '__init__' + ext)):
Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,18 @@ def test_splitdoc_with_description(self):

def test_is_package_when_not_package(self):
with os_helper.temp_cwd() as test_dir:
self.assertFalse(pydoc.ispackage(test_dir))
with self.assertWarns(DeprecationWarning) as cm:
self.assertFalse(pydoc.ispackage(test_dir))
self.assertEqual(cm.filename, __file__)

def test_is_package_when_is_package(self):
with os_helper.temp_cwd() as test_dir:
init_path = os.path.join(test_dir, '__init__.py')
open(init_path, 'w').close()
self.assertTrue(pydoc.ispackage(test_dir))
with self.assertWarns(DeprecationWarning) as cm:
self.assertTrue(pydoc.ispackage(test_dir))
os.remove(init_path)
self.assertEqual(cm.filename, __file__)

def test_allmethods(self):
# issue 17476: allmethods was no longer returning unbound methods.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The :func:`!pydoc.ispackage` function has been deprecated.