From 2bc0f2f7550e0a95d9535bf9a12ee2d49784e2bc Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 6 Nov 2024 01:28:17 +0100 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 6dba72cde6171bc1d1a4131a81a209ac9bfdf76b Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Wed Oct 2 16:13:50 2024 -0400 Enforce a non-None parent in build_function (#2562) It's a part of the campaign to get rid of non-module roots commit e3813e304f13f93a9eaa4677083697d33ccaf2d5 Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Wed Oct 2 14:19:23 2024 -0400 Set proper parents for namedtuple's and enum's (#2555) it's a part of the campaign to get rid of non-module roots commit be003599a9a7ae94a8f09a80ac9e0683cd133c20 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed Oct 2 11:20:50 2024 -0400 Remove unused numpy utility functions (#2595) Follow-up to c7ea1e941b4b88ec. commit d174ca24bde0bba7df63f024124381efe908330d Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed Oct 2 10:45:43 2024 -0400 Fix OverflowError with empty list and large multiplier This regressed in dfe1ccce8576. commit dfe1ccce8576fd5854e7eb578985d10f464c1b67 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed Oct 2 07:16:33 2024 -0400 Fix crashes with large positive and negative list multipliers Closes #2521 Closes #2523 commit ba7df4acab0e985d1a6274def9f1798a9a7ce40d Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue Oct 1 10:30:42 2024 +0200 [pre-commit.ci] pre-commit autoupdate (#2593) updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.7 → v0.6.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.7...v0.6.8) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit 8620ae14138c1df738c523e87fe8970cc76691da Author: Nick Drozd Date: Mon Sep 30 15:14:25 2024 -0400 Enable design complexity checks (#2591) commit 36094eddd69fe8c1862b6a6bd16024304e952b7a Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Mon Sep 30 15:14:13 2024 -0400 control setting nodes as local outside of the constructor (#2588) 1. The main reason is that a node might be assigned to its parent via an «alias»: Sometimes a class accesses a member by a different name than "__name__" of that member: in pypy3 `list.__mul__.__name__ == "__rmul__"`. As a result, in the example above we weren't able to find "list.__mul__", because it was recorded only as "list.__rmul__". 2. Sometimes we want to have a parent semantically, but we don't want to add it to the list of locals. For example, when inferring properties we are creating ad-hoc properties. We wouldn't want to add another symbol to the locals every time we do an inference. (actually, there's a very good question as to why we are doing those ad-hoc properties but that's out of scope) it's a part of the campaign to get rid of non-module roots commit 32cb29ebac7054fb23e9efcaa06319b9db601248 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Sep 30 20:33:57 2024 +0200 Bump actions/checkout from 4.1.7 to 4.2.0 (#2592) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4.1.7...v4.2.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit d394fb942eb18e690d0453bdd0a1e58c5beb219b Author: Jacob Walls Date: Mon Sep 30 08:52:35 2024 -0400 Bump astroid to 4.0.0-dev0, update changelog commit c7ea1e941b4b88ecf0470c9a5e5fd03215f84249 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sat Sep 7 14:47:47 2024 -0400 Consolidate numpy member transforms to reduce function calls commit f19fc0a52040293bede19d0ab83cd0613b73fb78 Author: Artem Yurchenko Date: Thu Sep 26 19:56:45 2024 -0700 disable AsyncGeneratorModel from inheriting Generator attributes for example, usual generators have "send", but async don't. They have "async" instead. commit 62c5badc838419090ee319acfcef3b651ffb1e94 Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Thu Sep 26 00:29:36 2024 -0400 change the type annotation error heuristic (#2583) The previous one depended on the message from "typed_ast", which is not used anymore. Instead, we check if there is a "# type:" substring in the source line of the exception. This can yield some false positives, but probably rarely. commit a3f5c4a397cb68b563e2c16a40bd623a53ad59b3 Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Wed Sep 25 16:18:58 2024 -0400 wrap GeneratorModel methods into BoundMethod; remove redundant test (#2584) The LookupTest.test_generator_attributes contains outdated Python 2 code (doesn't run on Python 3). The test is superceded by GeneratorModelTest.test_model. Fix AsyncGenerator test and model, they just weren't used before commit eb88dfed2671f81979abb644a92029a086d940d1 Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue Sep 24 06:47:29 2024 +0200 [pre-commit.ci] pre-commit autoupdate (#2582) updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.5 → v0.6.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.5...v0.6.7) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit c8e883107529552e7d4919d073f8ec2e7ca685bb Merge: 8585ce64 498cf960 Author: Jacob Walls Date: Mon Sep 23 14:33:13 2024 -0400 Merge pull request #2581 from pylint-dev/post-3.3.4 Post 3.3.4 commit 498cf960aa45622e8f5fde8c57177f2c495e2704 Merge: 8585ce64 6042e585 Author: Jacob Walls Date: Mon Sep 23 14:25:58 2024 -0400 Merge branch 'maintenance/3.3.x' into post-3.3.4 commit 8585ce64d2e53aeb556e3c49b866571f1276f9cb Author: Eric Vergnaud Date: Mon Sep 23 19:53:55 2024 +0200 Fix issue when inferring single-node or non-const JoinedStr (#2578) commit 706fcdbe43230900c4425f5b8896b114be4c1024 Author: Jacob Walls Date: Sun Sep 22 09:14:31 2024 -0400 Address pylint 3.3 messages (#2575) commit a679550d3dc87edaa35b334771527cba5102a373 Author: Nick Drozd Date: Sun Sep 22 09:00:09 2024 -0400 Check for empty format specs (#2574) commit 58286a1bbe55f41dc2eca0ae61755d030654f093 Author: Akhil Kamat Date: Sat Sep 21 21:36:35 2024 -0400 Fix `manager.clear_cache()` not fully clearing the module cache (#2572) commit 1368be19796430f4f1ee62f6e87b985e592b948c Merge: 5a93a9f9 11db16d2 Author: Jacob Walls Date: Fri Sep 20 08:10:58 2024 -0300 Merge pull request #2570 from pylint-dev/post-3.3.3 Post 3.3.3 commit 11db16d2bbc265ea9843d0b43b877c802cc6782b Merge: 5a93a9f9 a01a9c9f Author: Jacob Walls Date: Fri Sep 20 06:46:12 2024 -0400 Merge branch 'maintenance/3.3.x' into post-3.3.3 commit 5a93a9f9e7e8d1cbcbfc93783e86572b6c678152 Author: Jacob Walls Date: Thu Sep 19 09:43:50 2024 -0300 Fix inference regression with property setters (#2567) Closes pylint-dev/pylint#9811 commit 826d47708a3577deb7d3494e84c7b09fe4ad5bd3 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu Sep 19 12:05:44 2024 +0000 Bump actions/upload-artifact from 4.3.6 to 4.4.0 (#2533) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.6 to 4.4.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.3.6...v4.4.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 709f991aed8033beb6ea575188c96a6d75fd9c5a Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue Sep 17 07:04:26 2024 +0200 [pre-commit.ci] pre-commit autoupdate (#2565) updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.4 → v0.6.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.4...v0.6.5) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit a99967e0bf7cc89dd3677ec58a6861529d269f5d Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Fri Sep 13 11:35:02 2024 -0400 Require build class parent (#2557) * enforce a non-None parent in build_class We also remove `add_local_node` to avoid redundancy. Instead we do the attachment to the parent scope in the constructor of `ClassDef`. We append a node to the body of the frame when it is also the parent. If it's not a parent, then the node should belong to the "body" of the parent if it existed. An example is a definition within an "if", where the parent is the If node, but the frame is the whole module. it's a part of the campaign to get rid of non-module roots commit c7b8a2f1cf02b72fee706b523299eb29334536cd Author: akamat10 Date: Mon Sep 9 18:17:02 2024 -0400 add setuptools dependency for python >= 3.12 commit 44907c216fdd203f06b63589730998efbe527ae2 Author: akamat10 Date: Mon Sep 9 18:16:37 2024 -0400 Remove setuptools dependency from ci commit b4ac0e27ec76294eeed4f33b899525dea0acbc79 Author: Akhil Kamat Date: Wed Sep 11 06:06:28 2024 -0400 Remove newstyle variable given old-style class support should be removed (#2561) commit 523eeb4f1420b3dbcc0234cad0a8bbd69bc2c2ae Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Wed Sep 11 04:53:30 2024 -0400 Fix unexpected `__doc__` values (#2556) * fix unexpected '__doc__' values some '__doc__' fields of standard library symbols (e.g. WrapperDescriptorType.__doc__) don't return a string, they return a 'getset_descriptor'. Thus, an attempt to print "as string" fails. The solution is to check that __doc__ is an instance of str. Note that it wasn't uncovered by the tests due to classes not being attached to their parent in some cases. This is be done in one of the subsequent commits. it's a part of the campaign to get rid of non-module roots * put the "temporary_class" for the metaclass hack into adhoc module it's a part of the campaign to get rid of non-module roots commit e44277638d1af9de57dc6bb1aa61fdb66ef39296 Author: Artem Yurchenko Date: Mon Sep 9 11:31:27 2024 -0700 set PartialFunction's parent to adhoc module instead of Unknown it's a part of the campaign to get rid of non-module roots commit 83646936b71e588f0853697d4b9429df76507fda Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Tue Sep 10 15:32:07 2024 -0400 Fix in place properties (#2553) * fix construction of in-place properties This is an example of an in-place property: `bar = property(getter)`. They just create a nameless object, not the one with the name of the getter. Thus, the name was changed to "". Furthermore, the definition of that property is not attached to any scope, as it's again nameless. it's a part of the campaign to get rid of non-module roots commit 20890b81cebd40fc928834de64e48ff80100cec5 Author: Artem Yurchenko Date: Mon Sep 9 11:12:33 2024 -0700 set namespace's parent to adhoc module instead of Unknown it's a part of the campaign to get rid of non-module roots commit b6d52d321777c95bf7947e9352e8d02d709c70e4 Author: Artem Yurchenko Date: Mon Sep 9 11:04:34 2024 -0700 create an "adhoc" module for "artificial" nodes the module is specifically for nodes that are not based in the real syntactic tree, but created "ad-hoc", for example, new namedtuple classes that we create (see brain_namedtuple_enum). This is the base for future changes on replacing non-module roots (with the adhoc module or something more approriate). commit 6ec2d40660933575f93df4ff914ad2ba90c402f1 Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue Sep 10 06:15:01 2024 +0200 [pre-commit.ci] pre-commit autoupdate (#2559) updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.3 → v0.6.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.3...v0.6.4) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit 0011e7ffde2054d2b1c9e3b0de3689d11a706255 Author: Artem Yurchenko Date: Tue Sep 3 16:12:12 2024 -0700 add the parent node to "__main__" Not having a parent leads to weird situations, like `root()` returning the node itself, not a `Module`. commit 7954bac2f4e84e3f0b1096be246b238a5651c76e Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sat Sep 7 11:52:56 2024 -0400 Fix most of the mypy errors in astroid/nodes/as_string.py commit 8573b6820c727049d978dd796c0b378834da819b Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun Sep 8 03:15:01 2024 -0400 Fix useless-suppression Pylint warning (#2548) * Bump Pylint requirement to 3.2.7 commit cae2977d512bcb9fec077e99b6e03f038e912f2a Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun Sep 8 00:59:25 2024 -0400 Add .tox to Pylint ignore list (#2549) commit 887668b96b3ffe40ac4ab5fc71a0ea093ee66c11 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sat Sep 7 02:37:50 2024 -0400 Fix additional mypy errors and expand CI checks to more files (#2541) * Fix additional mypy errors and expand CI checks to more files * Use an assertion instead of a type ignore * Move an assert outside of a type-checking block commit ba331c036f544b9d892fa4eb6aade6c6b885af8f Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sat Sep 7 02:09:11 2024 -0400 Use extend-exclude instead of exclude in ruff config (#2545) The ruff docs recommend using extend-exclude for custom paths. commit 003a2df53b854d7b5a31e26f095d0585bcba1e18 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sat Sep 7 00:47:03 2024 -0400 Remove Python 3.8 from tox config (#2546) commit dc5dafb40ae3f8976d8d76d25cd056d7ce6b7718 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Fri Sep 6 01:37:53 2024 -0400 Avoid extra isinstance calls in _builtin_filter_predicate (#2544) commit 598261899eb0a3d599d419a5f4f726e84506cff7 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Thu Sep 5 15:29:25 2024 -0400 Move Pylint exclusions to pylintrc (#2542) This makes it easier to run Pylint outside of the pre-commit hooks. commit 71f5c0c84a4122edcb0fd638b284a0cf58a07a89 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed Sep 4 10:55:41 2024 -0400 Do not reassign submodule_path parameters in method bodies This makes it easier to use less generic annotations with mypy. commit 14959795899e8cef600689becaaaa6f31076ad8c Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed Sep 4 10:34:55 2024 -0400 Fix type annotations for tuple parameters commit 6deb34f41fd09e66a8106e1fd898e12e5d3b5ecd Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed Sep 4 02:04:09 2024 -0400 Add ruff exclusions to pyproject.toml (#2537) This makes it easier to run 'ruff check' outside of the pre-commit hook. Co-authored-by: Pierre Sassoulas commit 78f7f6032bb7a6d2d2e849f5abd9b2047dc8f844 Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue Sep 3 08:52:20 2024 +0200 [pre-commit.ci] pre-commit autoupdate (#2535) updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.2 → v0.6.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.2...v0.6.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit a30794c5a7e7698882a0022273f185f0b2c3d9cf Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Sep 2 20:09:47 2024 +0200 Bump actions/setup-python from 5.1.1 to 5.2.0 (#2534) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.1.1 to 5.2.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v5.1.1...v5.2.0) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 37b6c0df467425a3a70aac142ed993ee77d2b21b Author: temyurchenko <44875844+temyurchenko@users.noreply.github.com> Date: Fri Aug 30 17:30:56 2024 -0400 fix the documentation and the error message of modpath_from_file (#2532) The doc should clarify that the search will always include sys.path. The error message should reflect the actual paths used for checking. commit 5210e61d63e9deee5307a5df53bf5873380fee53 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Fri Aug 30 09:00:26 2024 -0400 Enable mypy checking for astroid/interpreter/_import/ (#2530) This commit also removes unnecessary tuple -> list conversions in _find_spec. commit a389ef79330a1dab7adb8d35f7035dfd90f99a66 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Tue Aug 27 17:19:26 2024 -0400 Use a tuple for processed parameter to facilitate future caching (#2529) commit 16990fcae373b33a5df7afdcc209bfaef1797a52 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Tue Aug 27 16:25:48 2024 -0400 Remove unnecessary isinstance calls from transform predicates (#2507) commit 0cf9a2ea5979948a38c89b8bf468353d43b65519 Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue Aug 27 06:34:11 2024 +0200 [pre-commit.ci] pre-commit autoupdate (#2528) updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.1 → v0.6.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.1...v0.6.2) - [github.com/pre-commit/mirrors-mypy: v1.11.1 → v1.11.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.1...v1.11.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit d8dbc462243a65d72153ace2e7ac87daa9ffc1cf Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun Aug 25 21:53:58 2024 -0400 Use a tuple for module_parts parameter to facilitate future caching commit f924ba2299328dc4d138ac9117edbfd0581f880b Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue Aug 20 06:15:34 2024 +0200 [pre-commit.ci] pre-commit autoupdate (#2512) updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.7 → v0.6.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.7...v0.6.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit b312b56ce582f85216500fe164640d01ea8f4a19 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun Aug 18 04:49:15 2024 +0000 Make Finder.find_module static to facilitate future caching (#2509) commit 8515010b9ab9d92b71f81b1b4df6983107741e75 Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue Aug 13 06:19:18 2024 +0200 [pre-commit.ci] pre-commit autoupdate (#2510) updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.6 → v0.5.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.6...v0.5.7) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit fa326738c9ff60e533abcb544c4f89ca4634b6bc Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Aug 12 22:35:41 2024 +0200 Bump actions/upload-artifact from 4.3.5 to 4.3.6 (#2508) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.5 to 4.3.6. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.3.5...v4.3.6) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 5e8fac7c5a3d00749d44315afa7ed0c5d9d4ecff Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun Aug 11 17:41:02 2024 +0000 Add cached version of os.path.isfile to avoid repetitive I/O (#2501) commit 3a743a4744ab5b0e03c7bb7f18cc7e6a736e8b00 Merge: 5b838f21 4df87085 Author: Jacob Walls Date: Sun Aug 11 10:18:28 2024 -0400 Merge pull request #2506 from pylint-dev/post-3.3.2 Post 3.3.2 commit 4df8708570950d4bcfc211b267deee9cc98a660f Merge: 86c78715 4ae46172 Author: Jacob Walls Date: Sun Aug 11 08:02:12 2024 -0400 Merge branch 'maintenance/3.3.x' into post-3.3.2 commit 5b838f21299e5a19b2598ba776b84caf19a651f8 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun Aug 11 13:50:27 2024 +0200 Update sphinx requirement from ~=7.4 to ~=8.0 (#2494) * Update sphinx requirement from ~=7.4 to ~=8.0 Updates the requirements on [sphinx](https://github.com/sphinx-doc/sphinx) to permit the latest version. - [Release notes](https://github.com/sphinx-doc/sphinx/releases) - [Changelog](https://github.com/sphinx-doc/sphinx/blob/v8.0.2/CHANGES.rst) - [Commits](https://github.com/sphinx-doc/sphinx/compare/v7.4.0...v8.0.2) --- updated-dependencies: - dependency-name: sphinx dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Upgrade furo too --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pierre Sassoulas commit 86c7871563a52e47466837d4a8c7a7a91e43bf46 Author: Jacob Walls Date: Sat Aug 10 17:06:09 2024 -0400 [PY313] Add stubs for soft-deprecated typing members (#2503) commit 0156c045346b231d4451e8aea85128dcf4e56c64 Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed Aug 7 11:57:49 2024 +0000 Avoid overhead of cast() calls when not type checking (#2500) commit 29b6cbd79d7654e5e2b50f60647e82aefd41c23e Author: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed Aug 7 11:48:42 2024 +0000 Avoid extra isinstance calls in _visit_generic (#2502) commit 15207a76b685f9d9bfda7a759afa27389ac4d233 Merge: 04f4f3ff 996ffea4 Author: Jacob Walls Date: Tue Aug 6 09:52:55 2024 -0400 Merge pull request #2499 from pylint-dev/post-3.3.1 commit 996ffea435e9309c540c047a3b1aa7c6ea0390a1 Merge: 04f4f3ff de58003b Author: Jacob Walls Date: Tue Aug 6 09:05:54 2024 -0400 Merge branch 'maintenance/3.3.x' into post-3.3.1 commit 04f4f3ff34e67bf00e8567752af92fac6f66e173 Author: Eric Vergnaud Date: Tue Aug 6 13:59:28 2024 +0200 Fix pylint regression with invalid format strings (#2496) Catch exceptions when calling string.format commit 8d3cdbbe6685fd8cf211816bec56c90f38f1859e Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon Aug 5 20:06:08 2024 -0400 [pre-commit.ci] pre-commit autoupdate (#2495) updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.5 → v0.5.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.5...v0.5.6) - [github.com/psf/black: 24.4.2 → 24.8.0](https://github.com/psf/black/compare/24.4.2...24.8.0) - [github.com/pre-commit/mirrors-mypy: v1.11.0 → v1.11.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.0...v1.11.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> commit 61dba89caea5419a5de59d0126aa537a81cba81f Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Aug 5 23:27:45 2024 +0200 Bump actions/upload-artifact from 4.3.4 to 4.3.5 (#2493) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.4 to 4.3.5. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.3.4...v4.3.5) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit b105186932f534864b75b7f35cd4127e89d0d90f Author: Jacob Walls Date: Sun Aug 4 09:10:21 2024 -0400 Bump astroid to 3.4.0-dev0, update changelog --- ChangeLog | 13 ++++--- astroid/brain/brain_namedtuple_enum.py | 48 ++++++++++++-------------- astroid/brain/brain_numpy_utils.py | 28 --------------- astroid/protocols.py | 5 ++- astroid/raw_building.py | 6 ++-- tests/test_protocols.py | 22 ++++++++++++ tests/test_raw_building.py | 10 +++--- 7 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e7a698d71..4b7d1fc234 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,13 @@ What's New in astroid 4.0.0? ============================ Release date: TBA +* Removed internal functions ``infer_numpy_member``, ``name_looks_like_numpy_member``, and + ``attribute_looks_like_numpy_member`` from ``astroid.brain.brain_numpy_utils``. + +* Fix crashes with large positive and negative list multipliers. + + Closes #2521 + Closes #2523 What's New in astroid 3.3.6? @@ -24,11 +31,7 @@ Release date: 2024-10-04 * Control setting local nodes outside of the supposed local's constructor. - Closes #1490 - -* Fix Python 3.13 compatibility re: `collections.abc` - - Closes pylint-dev/pylint#10000 + Closes pylint-dev/astroid/issues/1490 What's New in astroid 3.3.4? diff --git a/astroid/brain/brain_namedtuple_enum.py b/astroid/brain/brain_namedtuple_enum.py index b39d177b10..0c51b8b368 100644 --- a/astroid/brain/brain_namedtuple_enum.py +++ b/astroid/brain/brain_namedtuple_enum.py @@ -74,7 +74,9 @@ def _extract_namedtuple_arg_or_keyword( # pylint: disable=inconsistent-return-s def infer_func_form( node: nodes.Call, - base_type: list[nodes.NodeNG], + base_type: nodes.NodeNG, + *, + parent: nodes.NodeNG, context: InferenceContext | None = None, enum: bool = False, ) -> tuple[nodes.ClassDef, str, list[str]]: @@ -147,15 +149,10 @@ def infer_func_form( col_offset=node.col_offset, end_lineno=node.end_lineno, end_col_offset=node.end_col_offset, - parent=nodes.Unknown(), + parent=parent, ) - # A typical ClassDef automatically adds its name to the parent scope, - # but doing so causes problems, so defer setting parent until after init - # see: https://github.com/pylint-dev/pylint/issues/5982 - class_node.parent = node.parent class_node.postinit( - # set base class=tuple - bases=base_type, + bases=[base_type], body=[], decorators=None, ) @@ -195,25 +192,16 @@ def infer_named_tuple( node: nodes.Call, context: InferenceContext | None = None ) -> Iterator[nodes.ClassDef]: """Specific inference function for namedtuple Call node.""" - tuple_base_name: list[nodes.NodeNG] = [ - nodes.Name( - name="tuple", - parent=node.root(), - lineno=0, - col_offset=0, - end_lineno=None, - end_col_offset=None, - ) - ] + tuple_base: nodes.Name = _extract_single_node("tuple") class_node, name, attributes = infer_func_form( - node, tuple_base_name, context=context + node, tuple_base, parent=AstroidManager().adhoc_module, context=context ) + call_site = arguments.CallSite.from_call(node, context=context) - node = extract_node("import collections; collections.namedtuple") - try: - func = next(node.infer()) - except StopIteration as e: - raise InferenceError(node=node) from e + func = util.safe_infer( + _extract_single_node("import collections; collections.namedtuple") + ) + assert isinstance(func, nodes.NodeNG) try: rename = next( call_site.infer_argument(func, "rename", context or InferenceContext()) @@ -365,7 +353,17 @@ def value(self): __members__ = [''] """ ) - class_node = infer_func_form(node, [enum_meta], context=context, enum=True)[0] + + # FIXME arguably, the base here shouldn't be the EnumMeta class definition + # itself, but a reference (Name) to it. Otherwise, the invariant that all + # children of a node have that node as their parent is broken. + class_node = infer_func_form( + node, + enum_meta, + parent=AstroidManager().adhoc_module, + context=context, + enum=True, + )[0] return iter([class_node.instantiate_class()]) diff --git a/astroid/brain/brain_numpy_utils.py b/astroid/brain/brain_numpy_utils.py index 8ce7144372..a3d4ed5324 100644 --- a/astroid/brain/brain_numpy_utils.py +++ b/astroid/brain/brain_numpy_utils.py @@ -48,12 +48,6 @@ def infer_numpy_attribute( return extracted_node.infer(context=context) -# TODO: Deprecate and remove this function -def infer_numpy_member(src, node, context: InferenceContext | None = None): - node = extract_node(src) - return node.infer(context=context) - - def _is_a_numpy_module(node: Name) -> bool: """ Returns True if the node is a representation of a numpy module. @@ -96,25 +90,3 @@ def attribute_name_looks_like_numpy_member( and isinstance(node.expr, Name) and _is_a_numpy_module(node.expr) ) - - -# TODO: Deprecate and remove this function -def name_looks_like_numpy_member(member_name: str, node: Name) -> bool: - """ - Returns True if the Name is a member of numpy whose - name is member_name. - """ - return node.name == member_name and node.root().name.startswith("numpy") - - -# TODO: Deprecate and remove this function -def attribute_looks_like_numpy_member(member_name: str, node: Attribute) -> bool: - """ - Returns True if the Attribute is a member of numpy whose - name is member_name. - """ - return ( - node.attrname == member_name - and isinstance(node.expr, Name) - and _is_a_numpy_module(node.expr) - ) diff --git a/astroid/protocols.py b/astroid/protocols.py index 0bac32a29a..8a837b86b7 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -142,7 +142,10 @@ def _multiply_seq_by_int( context: InferenceContext, ) -> _TupleListNodeT: node = self.__class__(parent=opnode) - if value > 1e8: + if value <= 0 or not self.elts: + node.elts = [] + return node + if len(self.elts) * value > 1e8: node.elts = [util.Uninferable] return node filtered_elts = ( diff --git a/astroid/raw_building.py b/astroid/raw_building.py index b4e812f386..2d46706745 100644 --- a/astroid/raw_building.py +++ b/astroid/raw_building.py @@ -136,6 +136,7 @@ def build_class( def build_function( name: str, + parent: nodes.NodeNG, args: list[str] | None = None, posonlyargs: list[str] | None = None, defaults: list[Any] | None = None, @@ -149,7 +150,7 @@ def build_function( name, lineno=0, col_offset=0, - parent=node_classes.Unknown(), + parent=parent, end_col_offset=0, end_lineno=0, ) @@ -321,6 +322,7 @@ def object_build_function( return build_function( getattr(member, "__name__", ""), + node, args, posonlyargs, defaults, @@ -344,7 +346,7 @@ def object_build_methoddescriptor( """create astroid for a living method descriptor object""" # FIXME get arguments ? name = getattr(member, "__name__", "") - func = build_function(name, doc=member.__doc__) + func = build_function(name, node, doc=member.__doc__) _add_dunder_class(func, node, member) return func diff --git a/tests/test_protocols.py b/tests/test_protocols.py index 72b91a1156..4a9f1f6022 100644 --- a/tests/test_protocols.py +++ b/tests/test_protocols.py @@ -286,6 +286,28 @@ def test_uninferable_list_multiplication() -> None: element = parsed.inferred()[0].elts[0] assert element.value is Uninferable + @staticmethod + def test_uninferable_list_multiplication_with_multiple_operands() -> None: + """Attempting to calculate the result is prohibitively expensive.""" + parsed = extract_node("[0] * 825 * 16547118") + element = parsed.inferred()[0].elts[0] + assert element.value is Uninferable + + @staticmethod + def test_list_multiplication_with_empty_list_and_overflowing_multiplier() -> None: + parsed = extract_node("[] * 1163845194457646539560") + assert parsed.inferred()[0].elts == [] + + @staticmethod + def test_list_multiplication_with_zero_multiplier() -> None: + parsed = extract_node("[0] * 0") + assert parsed.inferred()[0].elts == [] + + @staticmethod + def test_list_multiplication_with_negative_overflowing_multiplier() -> None: + parsed = extract_node("[0] * -9223372036854775809") + assert parsed.inferred()[0].elts == [] + def test_named_expr_inference() -> None: code = """ diff --git a/tests/test_raw_building.py b/tests/test_raw_building.py index 1325dbc3ee..b5f3a62623 100644 --- a/tests/test_raw_building.py +++ b/tests/test_raw_building.py @@ -55,28 +55,28 @@ def test_build_class(self) -> None: self.assertEqual(node.doc_node, None) def test_build_function(self) -> None: - node = build_function("MyFunction") + node = build_function("MyFunction", DUMMY_MOD) self.assertEqual(node.name, "MyFunction") self.assertEqual(node.doc_node, None) def test_build_function_args(self) -> None: args = ["myArgs1", "myArgs2"] - node = build_function("MyFunction", args) + node = build_function("MyFunction", DUMMY_MOD, args) self.assertEqual("myArgs1", node.args.args[0].name) self.assertEqual("myArgs2", node.args.args[1].name) self.assertEqual(2, len(node.args.args)) def test_build_function_defaults(self) -> None: defaults = ["defaults1", "defaults2"] - node = build_function(name="MyFunction", args=None, defaults=defaults) + node = build_function("MyFunction", DUMMY_MOD, args=None, defaults=defaults) self.assertEqual(2, len(node.args.defaults)) def test_build_function_posonlyargs(self) -> None: - node = build_function(name="MyFunction", posonlyargs=["a", "b"]) + node = build_function("MyFunction", DUMMY_MOD, posonlyargs=["a", "b"]) self.assertEqual(2, len(node.args.posonlyargs)) def test_build_function_kwonlyargs(self) -> None: - node = build_function(name="MyFunction", kwonlyargs=["a", "b"]) + node = build_function("MyFunction", DUMMY_MOD, kwonlyargs=["a", "b"]) assert len(node.args.kwonlyargs) == 2 assert node.args.kwonlyargs[0].name == "a" assert node.args.kwonlyargs[1].name == "b"