Skip to content

Commit f020b2f

Browse files
Revert "Do not append namespace packages to sys.path (#6405)" (#6548)
This reverts commit 603be84.
1 parent 40ddfab commit f020b2f

7 files changed

Lines changed: 0 additions & 74 deletions

File tree

ChangeLog

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ Release date: TBA
2525

2626
Closes #4301
2727

28-
* By default the similarity checker will now ignore imports and ignore function signatures when computing
29-
duplication. If you want to keep the previous behaviour set ``ignore-imports`` and ``ignore-signatures`` to ``False``.
30-
31-
* Improved recognition of namespace packages. They should no longer be added to ``sys.path``
32-
which should prevent various issues with false positives.
33-
Because of the difficulties with mirroring the python import mechanics we would gladly
34-
hear feedback on this change.
35-
36-
Closes #5226, Closes #2648
37-
3828
* ``BaseChecker`` classes now require the ``linter`` argument to be passed.
3929

4030
* Fix a failure to respect inline disables for ``fixme`` occurring on the last line

doc/whatsnew/2.14.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@ Other Changes
129129

130130
Closes #4301
131131

132-
* Improved recognition of namespace packages. They should no longer be added to ``sys.path``
133-
which should prevent various issues with false positives.
134-
Because of the difficulties with mirroring the python import mechanics we would gladly
135-
hear feedback on this change.
136-
137-
Closes #5226, Closes #2648
138-
139132
* Update ``invalid-slots-object`` message to show bad object rather than its inferred value.
140133

141134
Closes #6101

pylint/lint/utils.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from datetime import datetime
1212
from pathlib import Path
1313

14-
from astroid import modutils
15-
1614
from pylint.config import PYLINT_HOME
1715
from pylint.lint.expand_modules import get_python_path
1816

@@ -73,29 +71,12 @@ def get_fatal_error_message(filepath: str, issue_template_path: Path) -> str:
7371
)
7472

7573

76-
def _is_part_of_namespace_package(filename: str) -> bool:
77-
"""Check if a file is part of a namespace package."""
78-
try:
79-
modname = modutils.modpath_from_file(filename)
80-
except ImportError:
81-
modname = [Path(filename).stem]
82-
83-
try:
84-
spec = modutils.file_info_from_modpath(modname)
85-
except ImportError:
86-
return False
87-
88-
return modutils.is_namespace(spec)
89-
90-
9174
def _patch_sys_path(args: Sequence[str]) -> list[str]:
9275
original = list(sys.path)
9376
changes = []
9477
seen = set()
9578
for arg in args:
9679
path = get_python_path(arg)
97-
if _is_part_of_namespace_package(path):
98-
continue
9980
if path not in seen:
10081
changes.append(path)
10182
seen.add(path)

tests/lint/test_namespace_packages.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/lint/unittest_expand_modules.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ def test__is_in_ignore_list_re_match() -> None:
7777
"path": str(TEST_DIRECTORY / "lint/test_caching.py"),
7878
}
7979

80-
test_namespace_packages = {
81-
"basename": "lint",
82-
"basepath": INIT_PATH,
83-
"isarg": False,
84-
"name": "lint.test_namespace_packages",
85-
"path": str(TEST_DIRECTORY / "lint/test_namespace_packages.py"),
86-
}
8780

8881
init_of_package = {
8982
"basename": "lint",
@@ -115,7 +108,6 @@ class Checker(BaseChecker):
115108
[
116109
init_of_package,
117110
test_caching,
118-
test_namespace_packages,
119111
test_pylinter,
120112
test_utils,
121113
this_file_from_init,

tests/regrtest_data/namespace_import_self/else/__init__.py

Whitespace-only changes.

tests/regrtest_data/namespace_import_self/pylint/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)