From 68c78e5c8d799fee964be84f8eda9d2207cb5543 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 4 Jan 2022 00:15:30 +0100 Subject: Fix a typo in the changelog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e2dfa508..6c56d234 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,7 @@ What's New in astroid 2.9.2? ============================ Release date: 2022-01-04 -* Fixed regression in ``astroid.scoped_nodes`` where ```_is_metaclass`` +* Fixed regression in ``astroid.scoped_nodes`` where ``_is_metaclass`` was not accessible anymore. Closes #1325 -- cgit v1.2.1 From a03c07d835d138086160fa2452b7b7297f41ed9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sun, 9 Jan 2022 16:57:55 +0100 Subject: Fix finding packages without an ``__init__.py`` (#1333) --- ChangeLog | 8 ++++++++ astroid/modutils.py | 8 +++++++- tests/unittest_modutils.py | 25 +++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6c56d234..783391c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,14 @@ What's New in astroid 2.10.0? Release date: TBA +What's New in astroid 2.9.3? +============================ +Release date: TBA + +* Fixed regression where packages without a ``__init__.py`` file were + not recognized or imported correctly. + + Closes #1327 What's New in astroid 2.9.2? ============================ diff --git a/astroid/modutils.py b/astroid/modutils.py index 6d698469..b20a1840 100644 --- a/astroid/modutils.py +++ b/astroid/modutils.py @@ -297,6 +297,9 @@ def _get_relative_base_path(filename, path_to_check): if os.path.normcase(real_filename).startswith(path_to_check): importable_path = real_filename + # if "var" in path_to_check: + # breakpoint() + if importable_path: base_path = os.path.splitext(importable_path)[0] relative_base_path = base_path[len(path_to_check) :] @@ -307,8 +310,11 @@ def _get_relative_base_path(filename, path_to_check): def modpath_from_file_with_callback(filename, path=None, is_package_cb=None): filename = os.path.expanduser(_path_from_filename(filename)) + paths_to_check = sys.path.copy() + if path: + paths_to_check += path for pathname in itertools.chain( - path or [], map(_cache_normalize_path, sys.path), sys.path + paths_to_check, map(_cache_normalize_path, paths_to_check) ): if not pathname: continue diff --git a/tests/unittest_modutils.py b/tests/unittest_modutils.py index d6fcb68e..01d5e5b9 100644 --- a/tests/unittest_modutils.py +++ b/tests/unittest_modutils.py @@ -30,6 +30,7 @@ import sys import tempfile import unittest import xml +from pathlib import Path from xml import etree from xml.etree import ElementTree @@ -189,6 +190,30 @@ class ModPathFromFileTest(unittest.TestCase): # this should be equivalent to: import secret self.assertEqual(modutils.modpath_from_file(symlink_secret_path), ["secret"]) + def test_load_packages_without_init(self) -> None: + """Test that we correctly find packages with an __init__.py file. + + Regression test for issue reported in: + https://github.com/PyCQA/astroid/issues/1327 + """ + tmp_dir = Path(tempfile.gettempdir()) + self.addCleanup(os.chdir, os.curdir) + os.chdir(tmp_dir) + + self.addCleanup(shutil.rmtree, tmp_dir / "src") + os.mkdir(tmp_dir / "src") + os.mkdir(tmp_dir / "src" / "package") + with open(tmp_dir / "src" / "__init__.py", "w", encoding="utf-8"): + pass + with open(tmp_dir / "src" / "package" / "file.py", "w", encoding="utf-8"): + pass + + # this should be equivalent to: import secret + self.assertEqual( + modutils.modpath_from_file(str(Path("src") / "package"), ["."]), + ["src", "package"], + ) + class LoadModuleFromPathTest(resources.SysPathSetup, unittest.TestCase): def test_do_not_load_twice(self) -> None: -- cgit v1.2.1 From d3449531aa5bcefb47cbb55ac695be5ed3dd635b Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 9 Jan 2022 11:22:43 +0100 Subject: Bump astroid to 2.9.3, update changelog --- ChangeLog | 8 +++++++- astroid/__pkginfo__.py | 2 +- doc/release.md | 14 ++++++++++++++ tbump.toml | 2 +- tests/unittest_modutils.py | 3 ++- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 783391c3..3bb23e2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,10 +7,16 @@ What's New in astroid 2.10.0? Release date: TBA -What's New in astroid 2.9.3? +What's New in astroid 2.9.4? ============================ Release date: TBA + + +What's New in astroid 2.9.3? +============================ +Release date: 2022-01-09 + * Fixed regression where packages without a ``__init__.py`` file were not recognized or imported correctly. diff --git a/astroid/__pkginfo__.py b/astroid/__pkginfo__.py index fb179675..849e09d5 100644 --- a/astroid/__pkginfo__.py +++ b/astroid/__pkginfo__.py @@ -24,5 +24,5 @@ # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE -__version__ = "2.9.2" +__version__ = "2.9.3" version = __version__ diff --git a/doc/release.md b/doc/release.md index a595207d..96855ef3 100644 --- a/doc/release.md +++ b/doc/release.md @@ -29,3 +29,17 @@ Check the result and then upgrade the main branch We move issue that were not done in the next milestone and block release only if it's an issue labelled as blocker. + +## Post release + +### Merge tags in main for pre-commit + +If the tag you just made is not part of the main branch, merge the tag `vX.Y.Z` in the +main branch by doing a history only merge. It's done in order to signal that this is an +official release tag, and for `pre-commit autoupdate` to works. + +```bash +git checkout main +git merge --no-edit --strategy=ours vX.Y.Z +git push +``` diff --git a/tbump.toml b/tbump.toml index a3305c24..60d7ccb3 100644 --- a/tbump.toml +++ b/tbump.toml @@ -1,7 +1,7 @@ github_url = "https://github.com/PyCQA/astroid" [version] -current = "2.9.2" +current = "2.9.3" regex = ''' ^(?P0|[1-9]\d*) \. diff --git a/tests/unittest_modutils.py b/tests/unittest_modutils.py index 01d5e5b9..e9e5743d 100644 --- a/tests/unittest_modutils.py +++ b/tests/unittest_modutils.py @@ -11,11 +11,12 @@ # Copyright (c) 2019 markmcclain # Copyright (c) 2020-2021 hippo91 # Copyright (c) 2020 Peter Kolbus +# Copyright (c) 2021-2022 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> # Copyright (c) 2021 Pierre Sassoulas -# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> # Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com> # Copyright (c) 2021 DudeNr33 <3929834+DudeNr33@users.noreply.github.com> # Copyright (c) 2021 pre-commit-ci[bot] +# Copyright (c) 2022 Alexander Shadchin # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE -- cgit v1.2.1 From 4fd3d347763c2358dc4d417d8b277db5a869ffd8 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 9 Jan 2022 11:24:54 +0100 Subject: Upgrade the version to 2.9.4-dev0 following 2.9.3 release --- astroid/__pkginfo__.py | 2 +- tbump.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/astroid/__pkginfo__.py b/astroid/__pkginfo__.py index 849e09d5..3d61098b 100644 --- a/astroid/__pkginfo__.py +++ b/astroid/__pkginfo__.py @@ -24,5 +24,5 @@ # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE -__version__ = "2.9.3" +__version__ = "2.9.4-dev0" version = __version__ diff --git a/tbump.toml b/tbump.toml index 60d7ccb3..847e1838 100644 --- a/tbump.toml +++ b/tbump.toml @@ -1,7 +1,7 @@ github_url = "https://github.com/PyCQA/astroid" [version] -current = "2.9.3" +current = "2.9.4-dev0" regex = ''' ^(?P0|[1-9]\d*) \. -- cgit v1.2.1