libv8 6.7.288.46.1 → 7.3.492.27.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/ext/libv8/builder.rb +6 -2
- data/lib/libv8/version.rb +1 -1
- data/vendor/depot_tools/.gitattributes +1 -0
- data/vendor/depot_tools/.gitignore +7 -0
- data/vendor/depot_tools/CROS_OWNERS +5 -0
- data/vendor/depot_tools/OWNERS +12 -1
- data/vendor/depot_tools/PRESUBMIT.py +16 -9
- data/vendor/depot_tools/README.md +9 -2
- data/vendor/depot_tools/autoninja +14 -6
- data/vendor/depot_tools/autoninja.bat +11 -1
- data/vendor/depot_tools/autoninja.py +40 -18
- data/vendor/depot_tools/bb +12 -0
- data/vendor/depot_tools/bb.bat +7 -0
- data/vendor/depot_tools/bootstrap/win/manifest.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/win_tools.py +2 -1
- data/vendor/depot_tools/buildbucket.py +57 -4
- data/vendor/depot_tools/cipd +157 -44
- data/vendor/depot_tools/cipd.bat +51 -14
- data/vendor/depot_tools/cipd.ps1 +104 -42
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_client_version.digests +21 -0
- data/vendor/depot_tools/cipd_manifest.txt +19 -6
- data/vendor/depot_tools/cipd_manifest.versions +318 -0
- data/vendor/depot_tools/clang_format.py +4 -4
- data/vendor/depot_tools/cpplint.py +44 -199
- data/vendor/depot_tools/dart_format.py +2 -2
- data/vendor/depot_tools/detect_host_arch.py +8 -3
- data/vendor/depot_tools/download_from_google_storage.py +47 -39
- data/vendor/depot_tools/fetch.py +30 -18
- data/vendor/depot_tools/fetch_configs/android_internal.py +34 -0
- data/vendor/depot_tools/fetch_configs/chromium.py +18 -1
- data/vendor/depot_tools/fetch_configs/config_util.py +4 -2
- data/vendor/depot_tools/fetch_configs/inspector_protocol.py +40 -0
- data/vendor/depot_tools/fetch_configs/node-ci.py +41 -0
- data/vendor/depot_tools/fix_encoding.py +3 -3
- data/vendor/depot_tools/gclient +1 -1
- data/vendor/depot_tools/gclient.py +415 -198
- data/vendor/depot_tools/gclient_eval.py +220 -171
- data/vendor/depot_tools/gclient_paths.py +142 -0
- data/vendor/depot_tools/gclient_scm.py +200 -51
- data/vendor/depot_tools/gclient_utils.py +88 -191
- data/vendor/depot_tools/gerrit_client.py +13 -0
- data/vendor/depot_tools/gerrit_util.py +158 -23
- data/vendor/depot_tools/git-nav-upstream +1 -1
- data/vendor/depot_tools/git_cache.py +77 -24
- data/vendor/depot_tools/git_cl.py +705 -1099
- data/vendor/depot_tools/git_common.py +9 -6
- data/vendor/depot_tools/git_map_branches.py +19 -2
- data/vendor/depot_tools/git_nav_downstream.py +3 -4
- data/vendor/depot_tools/git_rebase_update.py +14 -0
- data/vendor/depot_tools/git_reparent_branch.py +8 -2
- data/vendor/depot_tools/gn.py +38 -3
- data/vendor/depot_tools/gsutil.py +8 -3
- data/vendor/depot_tools/gsutil.py.bat +15 -0
- data/vendor/depot_tools/gsutil.vpython +16 -0
- data/vendor/depot_tools/infra/config/OWNERS +0 -1
- data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
- data/vendor/depot_tools/lucicfg +12 -0
- data/vendor/depot_tools/lucicfg.bat +7 -0
- data/vendor/depot_tools/man/html/git-map-branches.html +34 -2
- data/vendor/depot_tools/man/html/git-new-branch.html +40 -32
- data/vendor/depot_tools/man/man1/git-map-branches.1 +24 -5
- data/vendor/depot_tools/man/man1/git-new-branch.1 +35 -27
- data/vendor/depot_tools/man/src/git-map-branches.demo.1.sh +1 -0
- data/vendor/depot_tools/man/src/git-map-branches.txt +10 -0
- data/vendor/depot_tools/man/src/git-new-branch.demo.1.sh +9 -4
- data/vendor/depot_tools/man/src/git-new-branch.txt +1 -1
- data/vendor/depot_tools/metrics.README.md +98 -0
- data/vendor/depot_tools/metrics.py +296 -0
- data/vendor/depot_tools/metrics_utils.py +303 -0
- data/vendor/depot_tools/my_activity.py +91 -29
- data/vendor/depot_tools/ninja +1 -1
- data/vendor/depot_tools/ninjalog.README.md +64 -0
- data/vendor/depot_tools/ninjalog_uploader.py +232 -0
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +116 -0
- data/vendor/depot_tools/owners.py +30 -13
- data/vendor/depot_tools/owners_finder.py +5 -2
- data/vendor/depot_tools/presubmit_canned_checks.py +188 -29
- data/vendor/depot_tools/presubmit_support.py +18 -41
- data/vendor/depot_tools/pylintrc +23 -19
- data/vendor/depot_tools/recipes/OWNERS +2 -0
- data/vendor/depot_tools/recipes/README.recipes.md +344 -151
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/OWNERS +2 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +2 -16
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +141 -99
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +6 -98
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob.json → input_commit_with_id_without_repo.json} +6 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob_empty_revision.json → multiple_patch_refs.json} +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +19 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{trychange.json → refs.json} +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +50 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +26 -28
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +13 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name.json +13 -152
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +185 -202
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +52 -157
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +5 -14
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +34 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +14 -2
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +7 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +13 -8
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.py +3 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +58 -46
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +65 -22
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +5 -2
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +62 -14
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +24 -38
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +56 -50
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.py +15 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +4 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +34 -22
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +222 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +224 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +10 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +10 -5
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +12 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +27 -11
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +12 -13
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +120 -5
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +45 -3
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +56 -4
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +6 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.py +49 -0
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +24 -13
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +13 -14
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +1 -2
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +35 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +116 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +82 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +23 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +2 -7
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +7 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +117 -8
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +7 -4
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +98 -7
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +147 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +27 -2
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/test_api.py +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/__init__.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/api.py +137 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +107 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +26 -0
- data/vendor/depot_tools/recipes/recipes.py +37 -27
- data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +7 -10
- data/vendor/depot_tools/repo +34 -8
- data/vendor/depot_tools/roll_dep.py +52 -49
- data/vendor/depot_tools/scm.py +38 -23
- data/vendor/depot_tools/setup_color.py +4 -2
- data/vendor/depot_tools/split_cl.py +32 -4
- data/vendor/depot_tools/subprocess2.py +22 -4
- data/vendor/depot_tools/third_party/httplib2/README.chromium +2 -2
- data/vendor/depot_tools/third_party/httplib2/__init__.py +242 -158
- data/vendor/depot_tools/third_party/httplib2/cacerts.txt +57 -44
- data/vendor/depot_tools/third_party/httplib2/socks.py +15 -5
- data/vendor/depot_tools/third_party/logilab/README.chromium +2 -4
- data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +2 -1
- data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +10 -5
- data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +5 -5
- data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +233 -0
- data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +82 -33
- data/vendor/depot_tools/third_party/logilab/astroid/bases.py +137 -153
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{builtin_inference.py → brain_builtin_inference.py} +117 -26
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +15 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2gi.py → brain_gi.py} +48 -8
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2mechanize.py → brain_mechanize.py} +0 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pynose.py → brain_nose.py} +4 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +62 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +76 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +44 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pysix_moves.py → brain_six.py} +28 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +65 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +473 -0
- data/vendor/depot_tools/third_party/logilab/astroid/builder.py +104 -81
- data/vendor/depot_tools/third_party/logilab/astroid/context.py +81 -0
- data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +75 -0
- data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +20 -0
- data/vendor/depot_tools/third_party/logilab/astroid/inference.py +137 -183
- data/vendor/depot_tools/third_party/logilab/astroid/manager.py +45 -169
- data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +37 -14
- data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +112 -41
- data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +243 -156
- data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +35 -22
- data/vendor/depot_tools/third_party/logilab/astroid/objects.py +186 -0
- data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +157 -102
- data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +32 -8
- data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +372 -309
- data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +652 -420
- data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +4 -21
- data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +96 -0
- data/vendor/depot_tools/third_party/logilab/astroid/util.py +89 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +19 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +20 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +1421 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +9 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +246 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +414 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +13 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +24 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +19 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +2729 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +96 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +512 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +228 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +901 -0
- data/vendor/depot_tools/third_party/pylint/README.chromium +2 -25
- data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +13 -3
- data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +1 -2
- data/vendor/depot_tools/third_party/pylint/checkers/async.py +82 -0
- data/vendor/depot_tools/third_party/pylint/checkers/base.py +893 -119
- data/vendor/depot_tools/third_party/pylint/checkers/classes.py +342 -204
- data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +51 -34
- data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +84 -47
- data/vendor/depot_tools/third_party/pylint/checkers/format.py +55 -30
- data/vendor/depot_tools/third_party/pylint/checkers/imports.py +314 -73
- data/vendor/depot_tools/third_party/pylint/checkers/logging.py +10 -8
- data/vendor/depot_tools/third_party/pylint/checkers/misc.py +2 -1
- data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +45 -48
- data/vendor/depot_tools/third_party/pylint/checkers/python3.py +31 -21
- data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +3 -3
- data/vendor/depot_tools/third_party/pylint/checkers/similar.py +4 -5
- data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +24 -10
- data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +120 -56
- data/vendor/depot_tools/third_party/pylint/checkers/strings.py +38 -35
- data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +485 -138
- data/vendor/depot_tools/third_party/pylint/checkers/utils.py +319 -142
- data/vendor/depot_tools/third_party/pylint/checkers/variables.py +329 -207
- data/vendor/depot_tools/third_party/pylint/config.py +739 -76
- data/vendor/depot_tools/third_party/pylint/epylint.py +9 -5
- data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +311 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +62 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint}/graph.py +30 -133
- data/vendor/depot_tools/third_party/pylint/gui.py +2 -2
- data/vendor/depot_tools/third_party/pylint/interfaces.py +21 -3
- data/vendor/depot_tools/third_party/pylint/lint.py +123 -140
- data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +10 -13
- data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +15 -4
- data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +372 -0
- data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +30 -7
- data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +80 -2
- data/vendor/depot_tools/third_party/{logilab/common → pylint/pyreverse}/vcgutils.py +19 -37
- data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +3 -4
- data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +34 -18
- data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +1 -1
- data/vendor/depot_tools/third_party/pylint/reporters/html.py +10 -3
- data/vendor/depot_tools/third_party/pylint/reporters/json.py +10 -4
- data/vendor/depot_tools/third_party/pylint/reporters/text.py +94 -3
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +106 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/html_writer.py +17 -57
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/nodes.py +52 -74
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/text_writer.py +14 -60
- data/vendor/depot_tools/third_party/pylint/testutils.py +22 -20
- data/vendor/depot_tools/third_party/pylint/utils.py +268 -44
- data/vendor/depot_tools/third_party/repo/progress.py +42 -0
- data/vendor/depot_tools/update_depot_tools +1 -1
- data/vendor/depot_tools/upload_metrics.py +25 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +45 -15
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +71 -24
- data/vendor/depot_tools/yapf +1 -1
- data/vendor/depot_tools/yapf.bat +1 -1
- metadata +92 -77
- data/vendor/depot_tools/git-crsync +0 -3
- data/vendor/depot_tools/infra/config/cq.cfg +0 -32
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/buildbot.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/shallow.json +0 -195
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle_deprecated.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name_no_patch.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/apply_gerrit.py +0 -33
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2pytest.py +0 -31
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2qt4.py +0 -22
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2stdlib.py +0 -334
- data/vendor/depot_tools/third_party/logilab/astroid/inspector.py +0 -273
- data/vendor/depot_tools/third_party/logilab/astroid/utils.py +0 -239
- data/vendor/depot_tools/third_party/logilab/common/LICENSE.txt +0 -339
- data/vendor/depot_tools/third_party/logilab/common/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/common/__init__.py +0 -175
- data/vendor/depot_tools/third_party/logilab/common/__pkginfo__.py +0 -57
- data/vendor/depot_tools/third_party/logilab/common/cache.py +0 -114
- data/vendor/depot_tools/third_party/logilab/common/changelog.py +0 -238
- data/vendor/depot_tools/third_party/logilab/common/clcommands.py +0 -334
- data/vendor/depot_tools/third_party/logilab/common/cli.py +0 -211
- data/vendor/depot_tools/third_party/logilab/common/compat.py +0 -78
- data/vendor/depot_tools/third_party/logilab/common/configuration.py +0 -1105
- data/vendor/depot_tools/third_party/logilab/common/contexts.py +0 -5
- data/vendor/depot_tools/third_party/logilab/common/corbautils.py +0 -117
- data/vendor/depot_tools/third_party/logilab/common/daemon.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/date.py +0 -335
- data/vendor/depot_tools/third_party/logilab/common/dbf.py +0 -231
- data/vendor/depot_tools/third_party/logilab/common/debugger.py +0 -214
- data/vendor/depot_tools/third_party/logilab/common/decorators.py +0 -281
- data/vendor/depot_tools/third_party/logilab/common/deprecation.py +0 -189
- data/vendor/depot_tools/third_party/logilab/common/fileutils.py +0 -404
- data/vendor/depot_tools/third_party/logilab/common/interface.py +0 -71
- data/vendor/depot_tools/third_party/logilab/common/logging_ext.py +0 -195
- data/vendor/depot_tools/third_party/logilab/common/modutils.py +0 -702
- data/vendor/depot_tools/third_party/logilab/common/optik_ext.py +0 -392
- data/vendor/depot_tools/third_party/logilab/common/optparser.py +0 -92
- data/vendor/depot_tools/third_party/logilab/common/proc.py +0 -277
- data/vendor/depot_tools/third_party/logilab/common/pyro_ext.py +0 -180
- data/vendor/depot_tools/third_party/logilab/common/pytest.py +0 -1199
- data/vendor/depot_tools/third_party/logilab/common/registry.py +0 -1119
- data/vendor/depot_tools/third_party/logilab/common/shellutils.py +0 -462
- data/vendor/depot_tools/third_party/logilab/common/sphinx_ext.py +0 -87
- data/vendor/depot_tools/third_party/logilab/common/sphinxutils.py +0 -122
- data/vendor/depot_tools/third_party/logilab/common/table.py +0 -929
- data/vendor/depot_tools/third_party/logilab/common/tasksqueue.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/testlib.py +0 -1392
- data/vendor/depot_tools/third_party/logilab/common/textutils.py +0 -537
- data/vendor/depot_tools/third_party/logilab/common/tree.py +0 -369
- data/vendor/depot_tools/third_party/logilab/common/umessage.py +0 -194
- data/vendor/depot_tools/third_party/logilab/common/ureports/__init__.py +0 -172
- data/vendor/depot_tools/third_party/logilab/common/ureports/docbook_writer.py +0 -140
- data/vendor/depot_tools/third_party/logilab/common/urllib2ext.py +0 -89
- data/vendor/depot_tools/third_party/logilab/common/visitor.py +0 -109
- data/vendor/depot_tools/third_party/logilab/common/xmlrpcutils.py +0 -131
- data/vendor/depot_tools/third_party/logilab/common/xmlutils.py +0 -61
@@ -15,40 +15,33 @@
|
|
15
15
|
#
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License along
|
17
17
|
# with astroid. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
"""This module contains the classes for "scoped" node, i.e. which are opening a
|
19
|
-
new local scope in the language definition : Module, Class, Function (and
|
20
|
-
Lambda, GenExpr, DictComp and SetComp to some extent).
|
21
|
-
"""
|
22
|
-
from __future__ import with_statement
|
23
18
|
|
24
|
-
|
19
|
+
"""
|
20
|
+
This module contains the classes for "scoped" node, i.e. which are opening a
|
21
|
+
new local scope in the language definition : Module, ClassDef, FunctionDef (and
|
22
|
+
Lambda, GeneratorExp, DictComp and SetComp to some extent).
|
23
|
+
"""
|
25
24
|
|
26
|
-
import
|
25
|
+
import io
|
26
|
+
import itertools
|
27
27
|
import warnings
|
28
|
-
from itertools import chain
|
29
|
-
try:
|
30
|
-
from io import BytesIO
|
31
|
-
except ImportError:
|
32
|
-
from cStringIO import StringIO as BytesIO
|
33
28
|
|
34
29
|
import six
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
from astroid
|
39
|
-
|
40
|
-
from astroid
|
41
|
-
|
42
|
-
|
43
|
-
from astroid
|
44
|
-
|
45
|
-
|
46
|
-
from astroid.mixins import FilterStmtsMixin
|
47
|
-
from astroid.bases import Statement
|
48
|
-
from astroid.manager import AstroidManager
|
30
|
+
import wrapt
|
31
|
+
|
32
|
+
from astroid import bases
|
33
|
+
from astroid import context as contextmod
|
34
|
+
from astroid import exceptions
|
35
|
+
from astroid import manager
|
36
|
+
from astroid import mixins
|
37
|
+
from astroid import node_classes
|
38
|
+
from astroid import decorators as decorators_mod
|
39
|
+
from astroid import util
|
40
|
+
|
49
41
|
|
42
|
+
BUILTINS = six.moves.builtins.__name__
|
50
43
|
ITER_METHODS = ('__iter__', '__getitem__')
|
51
|
-
|
44
|
+
|
52
45
|
|
53
46
|
def _c3_merge(sequences):
|
54
47
|
"""Merges MROs in *sequences* to a single MRO using the C3 algorithm.
|
@@ -75,8 +68,10 @@ def _c3_merge(sequences):
|
|
75
68
|
bases = ["({})".format(", ".join(base.name
|
76
69
|
for base in subsequence))
|
77
70
|
for subsequence in sequences]
|
78
|
-
raise
|
79
|
-
|
71
|
+
raise exceptions.InconsistentMroError(
|
72
|
+
"Cannot create a consistent method resolution "
|
73
|
+
"order for bases %s" % ", ".join(bases))
|
74
|
+
|
80
75
|
result.append(candidate)
|
81
76
|
# remove the chosen candidate
|
82
77
|
for seq in sequences:
|
@@ -88,59 +83,62 @@ def _verify_duplicates_mro(sequences):
|
|
88
83
|
for sequence in sequences:
|
89
84
|
names = [node.qname() for node in sequence]
|
90
85
|
if len(names) != len(set(names)):
|
91
|
-
raise
|
86
|
+
raise exceptions.DuplicateBasesError('Duplicates found in the mro.')
|
92
87
|
|
93
88
|
|
94
|
-
def remove_nodes(
|
95
|
-
|
89
|
+
def remove_nodes(cls):
|
90
|
+
@wrapt.decorator
|
91
|
+
def decorator(func, instance, args, kwargs):
|
96
92
|
nodes = [n for n in func(*args, **kwargs) if not isinstance(n, cls)]
|
97
93
|
if not nodes:
|
98
|
-
raise NotFoundError()
|
94
|
+
raise exceptions.NotFoundError()
|
99
95
|
return nodes
|
100
|
-
return
|
96
|
+
return decorator
|
101
97
|
|
102
98
|
|
103
99
|
def function_to_method(n, klass):
|
104
|
-
if isinstance(n,
|
100
|
+
if isinstance(n, FunctionDef):
|
105
101
|
if n.type == 'classmethod':
|
106
|
-
return BoundMethod(n, klass)
|
102
|
+
return bases.BoundMethod(n, klass)
|
107
103
|
if n.type != 'staticmethod':
|
108
|
-
return UnboundMethod(n)
|
104
|
+
return bases.UnboundMethod(n)
|
109
105
|
return n
|
110
106
|
|
107
|
+
|
111
108
|
def std_special_attributes(self, name, add_locals=True):
|
112
109
|
if add_locals:
|
113
|
-
locals = self.
|
110
|
+
locals = self._locals
|
114
111
|
else:
|
115
112
|
locals = {}
|
116
113
|
if name == '__name__':
|
117
|
-
return [
|
114
|
+
return [node_classes.const_factory(self.name)] + locals.get(name, [])
|
118
115
|
if name == '__doc__':
|
119
|
-
return [
|
116
|
+
return [node_classes.const_factory(self.doc)] + locals.get(name, [])
|
120
117
|
if name == '__dict__':
|
121
|
-
return [Dict()] + locals.get(name, [])
|
122
|
-
raise NotFoundError(name)
|
118
|
+
return [node_classes.Dict()] + locals.get(name, [])
|
119
|
+
raise exceptions.NotFoundError(name)
|
123
120
|
|
124
|
-
|
121
|
+
|
122
|
+
MANAGER = manager.AstroidManager()
|
125
123
|
def builtin_lookup(name):
|
126
124
|
"""lookup a name into the builtin module
|
127
125
|
return the list of matching statements and the astroid for the builtin
|
128
126
|
module
|
129
127
|
"""
|
130
|
-
builtin_astroid = MANAGER.ast_from_module(builtins)
|
128
|
+
builtin_astroid = MANAGER.ast_from_module(six.moves.builtins)
|
131
129
|
if name == '__dict__':
|
132
130
|
return builtin_astroid, ()
|
133
131
|
try:
|
134
|
-
stmts = builtin_astroid.
|
132
|
+
stmts = builtin_astroid._locals[name]
|
135
133
|
except KeyError:
|
136
134
|
stmts = ()
|
137
135
|
return builtin_astroid, stmts
|
138
136
|
|
139
137
|
|
140
|
-
# TODO move this Mixin to mixins.py; problem: '
|
141
|
-
class LocalsDictNodeNG(LookupMixIn, NodeNG):
|
142
|
-
""" this class provides locals handling common to Module,
|
143
|
-
and
|
138
|
+
# TODO move this Mixin to mixins.py; problem: 'FunctionDef' in _scope_lookup
|
139
|
+
class LocalsDictNodeNG(node_classes.LookupMixIn, bases.NodeNG):
|
140
|
+
""" this class provides locals handling common to Module, FunctionDef
|
141
|
+
and ClassDef nodes, including a dict like interface for direct access
|
144
142
|
to locals information
|
145
143
|
"""
|
146
144
|
|
@@ -148,6 +146,18 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
|
|
148
146
|
|
149
147
|
# dictionary of locals with name as key and node defining the local as
|
150
148
|
# value
|
149
|
+
@property
|
150
|
+
def locals(self):
|
151
|
+
util.attribute_to_function_warning('locals', 2.0, 'get_locals')
|
152
|
+
return self._locals
|
153
|
+
@locals.setter
|
154
|
+
def locals(self, _locals):
|
155
|
+
util.attribute_to_function_warning('locals', 2.0, 'get_locals')
|
156
|
+
self._locals = _locals
|
157
|
+
@locals.deleter
|
158
|
+
def locals(self):
|
159
|
+
util.attribute_to_function_warning('locals', 2.0, 'get_locals')
|
160
|
+
del self._locals
|
151
161
|
|
152
162
|
def qname(self):
|
153
163
|
"""return the 'qualified' name of the node, eg module.name,
|
@@ -158,21 +168,20 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
|
|
158
168
|
return '%s.%s' % (self.parent.frame().qname(), self.name)
|
159
169
|
|
160
170
|
def frame(self):
|
161
|
-
"""return the first parent frame node (i.e. Module,
|
171
|
+
"""return the first parent frame node (i.e. Module, FunctionDef or ClassDef)
|
162
172
|
"""
|
163
173
|
return self
|
164
174
|
|
165
175
|
def scope(self):
|
166
176
|
"""return the first node defining a new scope (i.e. Module,
|
167
|
-
|
177
|
+
FunctionDef, ClassDef, Lambda but also GeneratorExp, DictComp and SetComp)
|
168
178
|
"""
|
169
179
|
return self
|
170
180
|
|
171
|
-
|
172
181
|
def _scope_lookup(self, node, name, offset=0):
|
173
182
|
"""XXX method for interfacing the scope lookup"""
|
174
183
|
try:
|
175
|
-
stmts = node._filter_stmts(self.
|
184
|
+
stmts = node._filter_stmts(self._locals[name], self, offset)
|
176
185
|
except KeyError:
|
177
186
|
stmts = ()
|
178
187
|
if stmts:
|
@@ -186,8 +195,6 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
|
|
186
195
|
return pscope.scope_lookup(node, name)
|
187
196
|
return builtin_lookup(name) # Module
|
188
197
|
|
189
|
-
|
190
|
-
|
191
198
|
def set_local(self, name, stmt):
|
192
199
|
"""define <name> in locals (<stmt> is the node defining the name)
|
193
200
|
if the node is a Module node (i.e. has globals), add the name to
|
@@ -195,8 +202,8 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
|
|
195
202
|
|
196
203
|
if the name is already defined, ignore it
|
197
204
|
"""
|
198
|
-
#assert not stmt in self.
|
199
|
-
self.
|
205
|
+
#assert not stmt in self._locals.get(name, ()), (self, stmt)
|
206
|
+
self._locals.setdefault(name, []).append(stmt)
|
200
207
|
|
201
208
|
__setitem__ = set_local
|
202
209
|
|
@@ -212,7 +219,6 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
|
|
212
219
|
self._append_node(child_node)
|
213
220
|
self.set_local(name or child_node.name, child_node)
|
214
221
|
|
215
|
-
|
216
222
|
def __getitem__(self, item):
|
217
223
|
"""method from the `dict` interface returning the first node
|
218
224
|
associated with the given name in the locals dictionary
|
@@ -221,7 +227,7 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
|
|
221
227
|
:param item: the name of the locally defined object
|
222
228
|
:raises KeyError: if the name is not defined
|
223
229
|
"""
|
224
|
-
return self.
|
230
|
+
return self._locals[item][0]
|
225
231
|
|
226
232
|
def __iter__(self):
|
227
233
|
"""method from the `dict` interface returning an iterator on
|
@@ -233,27 +239,24 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
|
|
233
239
|
"""method from the `dict` interface returning a tuple containing
|
234
240
|
locally defined names
|
235
241
|
"""
|
236
|
-
return list(self.
|
242
|
+
return list(self._locals.keys())
|
237
243
|
|
238
244
|
def values(self):
|
239
245
|
"""method from the `dict` interface returning a tuple containing
|
240
|
-
locally defined nodes which are instance of `
|
246
|
+
locally defined nodes which are instance of `FunctionDef` or `ClassDef`
|
241
247
|
"""
|
242
248
|
return [self[key] for key in self.keys()]
|
243
249
|
|
244
250
|
def items(self):
|
245
251
|
"""method from the `dict` interface returning a list of tuple
|
246
252
|
containing each locally defined name with its associated node,
|
247
|
-
which is an instance of `
|
253
|
+
which is an instance of `FunctionDef` or `ClassDef`
|
248
254
|
"""
|
249
255
|
return list(zip(self.keys(), self.values()))
|
250
256
|
|
251
|
-
|
252
257
|
def __contains__(self, name):
|
253
|
-
return name in self.
|
254
|
-
has_key = __contains__
|
258
|
+
return name in self._locals
|
255
259
|
|
256
|
-
# Module #####################################################################
|
257
260
|
|
258
261
|
class Module(LocalsDictNodeNG):
|
259
262
|
_astroid_fields = ('body',)
|
@@ -265,9 +268,9 @@ class Module(LocalsDictNodeNG):
|
|
265
268
|
|
266
269
|
# the file from which as been extracted the astroid representation. It may
|
267
270
|
# be None if the representation has been built from a built-in module
|
268
|
-
|
271
|
+
source_file = None
|
269
272
|
# Alternatively, if built from a string/bytes, this can be set
|
270
|
-
|
273
|
+
source_code = None
|
271
274
|
# encoding of python source file, so we can get unicode out of it (python2
|
272
275
|
# only)
|
273
276
|
file_encoding = None
|
@@ -279,10 +282,10 @@ class Module(LocalsDictNodeNG):
|
|
279
282
|
package = None
|
280
283
|
# dictionary of globals with name as key and node defining the global
|
281
284
|
# as value
|
282
|
-
|
285
|
+
_globals = None
|
283
286
|
|
284
287
|
# Future imports
|
285
|
-
|
288
|
+
_future_imports = None
|
286
289
|
|
287
290
|
# names of python special attributes (handled by getattr impl.)
|
288
291
|
special_attributes = set(('__name__', '__doc__', '__file__', '__path__',
|
@@ -294,15 +297,81 @@ class Module(LocalsDictNodeNG):
|
|
294
297
|
self.name = name
|
295
298
|
self.doc = doc
|
296
299
|
self.pure_python = pure_python
|
297
|
-
self.
|
300
|
+
self._locals = self._globals = {}
|
298
301
|
self.body = []
|
299
|
-
self.
|
302
|
+
self._future_imports = set()
|
303
|
+
|
304
|
+
# Future deprecation warnings
|
305
|
+
@property
|
306
|
+
def file(self):
|
307
|
+
util.rename_warning('file', 2.0, 'source_file')
|
308
|
+
return self.source_file
|
309
|
+
@file.setter
|
310
|
+
def file(self, source_file):
|
311
|
+
util.rename_warning('file', 2.0, 'source_file')
|
312
|
+
self.source_file = source_file
|
313
|
+
@file.deleter
|
314
|
+
def file(self):
|
315
|
+
util.rename_warning('file', 2.0, 'source_file')
|
316
|
+
del self.source_file
|
317
|
+
|
318
|
+
@property
|
319
|
+
def path(self):
|
320
|
+
util.rename_warning('path', 2.0, 'source_file')
|
321
|
+
return self.source_file
|
322
|
+
@path.setter
|
323
|
+
def path(self, source_file):
|
324
|
+
util.rename_warning('path', 2.0, 'source_file')
|
325
|
+
self.source_file = source_file
|
326
|
+
@path.deleter
|
327
|
+
def path(self):
|
328
|
+
util.rename_warning('path', 2.0, 'source_file')
|
329
|
+
del self.source_file
|
330
|
+
|
331
|
+
@property
|
332
|
+
def file_bytes(self):
|
333
|
+
util.rename_warning('file_bytes', 2.0, 'source_code')
|
334
|
+
return self.source_code
|
335
|
+
@file_bytes.setter
|
336
|
+
def file_bytes(self, source_code):
|
337
|
+
util.rename_warning('file_bytes', 2.0, 'source_code')
|
338
|
+
self.source_code = source_code
|
339
|
+
@file_bytes.deleter
|
340
|
+
def file_bytes(self):
|
341
|
+
util.rename_warning('file_bytes', 2.0, 'source_code')
|
342
|
+
del self.source_code
|
343
|
+
|
344
|
+
@property
|
345
|
+
def globals(self):
|
346
|
+
util.attribute_to_function_warning('globals', 2.0, 'get_locals')
|
347
|
+
return self._locals
|
348
|
+
@globals.setter
|
349
|
+
def globals(self, _globals):
|
350
|
+
util.attribute_to_function_warning('globals', 2.0, 'get_locals')
|
351
|
+
self._locals = _globals
|
352
|
+
@globals.deleter
|
353
|
+
def globals(self):
|
354
|
+
util.attribute_to_function_warning('globals', 2.0, 'get_locals')
|
355
|
+
del self._locals
|
356
|
+
|
357
|
+
@property
|
358
|
+
def future_imports(self):
|
359
|
+
util.attribute_to_function_warning('future_imports', 2.0, 'future_imports')
|
360
|
+
return self._future_imports
|
361
|
+
@future_imports.setter
|
362
|
+
def future_imports(self, _future_imports):
|
363
|
+
util.attribute_to_function_warning('future_imports', 2.0, 'future_imports')
|
364
|
+
self._future_imports = _future_imports
|
365
|
+
@future_imports.deleter
|
366
|
+
def future_imports(self):
|
367
|
+
util.attribute_to_function_warning('future_imports', 2.0, 'future_imports')
|
368
|
+
del self._future_imports
|
300
369
|
|
301
370
|
def _get_stream(self):
|
302
|
-
if self.
|
303
|
-
return BytesIO(self.
|
304
|
-
if self.
|
305
|
-
stream = open(self.
|
371
|
+
if self.source_code is not None:
|
372
|
+
return io.BytesIO(self.source_code)
|
373
|
+
if self.source_file is not None:
|
374
|
+
stream = open(self.source_file, 'rb')
|
306
375
|
return stream
|
307
376
|
return None
|
308
377
|
|
@@ -337,10 +406,10 @@ class Module(LocalsDictNodeNG):
|
|
337
406
|
return self.fromlineno, self.tolineno
|
338
407
|
|
339
408
|
def scope_lookup(self, node, name, offset=0):
|
340
|
-
if name in self.scope_attrs and not
|
409
|
+
if name in self.scope_attrs and name not in self._locals:
|
341
410
|
try:
|
342
411
|
return self, self.getattr(name)
|
343
|
-
except NotFoundError:
|
412
|
+
except exceptions.NotFoundError:
|
344
413
|
return self, ()
|
345
414
|
return self._scope_lookup(node, name, offset)
|
346
415
|
|
@@ -350,44 +419,42 @@ class Module(LocalsDictNodeNG):
|
|
350
419
|
def display_type(self):
|
351
420
|
return 'Module'
|
352
421
|
|
422
|
+
@remove_nodes(node_classes.DelName)
|
353
423
|
def getattr(self, name, context=None, ignore_locals=False):
|
354
424
|
if name in self.special_attributes:
|
355
425
|
if name == '__file__':
|
356
|
-
return [
|
426
|
+
return [node_classes.const_factory(self.source_file)] + self._locals.get(name, [])
|
357
427
|
if name == '__path__' and self.package:
|
358
|
-
return [List()] + self.
|
428
|
+
return [node_classes.List()] + self._locals.get(name, [])
|
359
429
|
return std_special_attributes(self, name)
|
360
|
-
if not ignore_locals and name in self.
|
361
|
-
return self.
|
430
|
+
if not ignore_locals and name in self._locals:
|
431
|
+
return self._locals[name]
|
362
432
|
if self.package:
|
363
433
|
try:
|
364
434
|
return [self.import_module(name, relative_only=True)]
|
365
|
-
except AstroidBuildingException:
|
366
|
-
raise NotFoundError(name)
|
435
|
+
except exceptions.AstroidBuildingException:
|
436
|
+
raise exceptions.NotFoundError(name)
|
367
437
|
except SyntaxError:
|
368
|
-
raise NotFoundError(name)
|
369
|
-
|
370
|
-
import traceback
|
371
|
-
traceback.print_exc()
|
372
|
-
raise NotFoundError(name)
|
373
|
-
getattr = remove_nodes(getattr, DelName)
|
438
|
+
raise exceptions.NotFoundError(name)
|
439
|
+
raise exceptions.NotFoundError(name)
|
374
440
|
|
375
441
|
def igetattr(self, name, context=None):
|
376
442
|
"""inferred getattr"""
|
377
443
|
# set lookup name since this is necessary to infer on import nodes for
|
378
444
|
# instance
|
379
|
-
context = copy_context(context)
|
445
|
+
context = contextmod.copy_context(context)
|
380
446
|
context.lookupname = name
|
381
447
|
try:
|
382
|
-
return _infer_stmts(self.getattr(name, context),
|
383
|
-
|
384
|
-
|
448
|
+
return bases._infer_stmts(self.getattr(name, context),
|
449
|
+
context, frame=self)
|
450
|
+
except exceptions.NotFoundError:
|
451
|
+
raise exceptions.InferenceError(name)
|
385
452
|
|
386
453
|
def fully_defined(self):
|
387
454
|
"""return True if this module has been built from a .py file
|
388
455
|
and so contains a complete representation including the code
|
389
456
|
"""
|
390
|
-
return self.
|
457
|
+
return self.source_file is not None and self.source_file.endswith('.py')
|
391
458
|
|
392
459
|
def statement(self):
|
393
460
|
"""return the first parent node marked as statement node
|
@@ -403,11 +470,11 @@ class Module(LocalsDictNodeNG):
|
|
403
470
|
"""module has no sibling"""
|
404
471
|
return
|
405
472
|
|
406
|
-
if
|
407
|
-
@cachedproperty
|
473
|
+
if six.PY2:
|
474
|
+
@decorators_mod.cachedproperty
|
408
475
|
def _absolute_import_activated(self):
|
409
|
-
for stmt in self.
|
410
|
-
if isinstance(stmt,
|
476
|
+
for stmt in self._locals.get('absolute_import', ()):
|
477
|
+
if isinstance(stmt, node_classes.ImportFrom) and stmt.modname == '__future__':
|
411
478
|
return True
|
412
479
|
return False
|
413
480
|
else:
|
@@ -423,7 +490,7 @@ class Module(LocalsDictNodeNG):
|
|
423
490
|
absmodname = self.relative_to_absolute_name(modname, level)
|
424
491
|
try:
|
425
492
|
return MANAGER.ast_from_module_name(absmodname)
|
426
|
-
except AstroidBuildingException:
|
493
|
+
except exceptions.AstroidBuildingException:
|
427
494
|
# we only want to import a sub module or package of this module,
|
428
495
|
# skip here
|
429
496
|
if relative_only:
|
@@ -454,7 +521,6 @@ class Module(LocalsDictNodeNG):
|
|
454
521
|
return '%s.%s' % (package_name, modname)
|
455
522
|
return modname
|
456
523
|
|
457
|
-
|
458
524
|
def wildcard_import_names(self):
|
459
525
|
"""return the list of imported names when this module is 'wildcard
|
460
526
|
imported'
|
@@ -462,19 +528,6 @@ class Module(LocalsDictNodeNG):
|
|
462
528
|
It doesn't include the '__builtins__' name which is added by the
|
463
529
|
current CPython implementation of wildcard imports.
|
464
530
|
"""
|
465
|
-
# take advantage of a living module if it exists
|
466
|
-
try:
|
467
|
-
living = sys.modules[self.name]
|
468
|
-
except KeyError:
|
469
|
-
pass
|
470
|
-
else:
|
471
|
-
try:
|
472
|
-
return living.__all__
|
473
|
-
except AttributeError:
|
474
|
-
return [name for name in living.__dict__.keys()
|
475
|
-
if not name.startswith('_')]
|
476
|
-
# else lookup the astroid
|
477
|
-
#
|
478
531
|
# We separate the different steps of lookup in try/excepts
|
479
532
|
# to avoid catching too many Exceptions
|
480
533
|
default = [name for name in self.keys() if not name.startswith('_')]
|
@@ -482,9 +535,10 @@ class Module(LocalsDictNodeNG):
|
|
482
535
|
all = self['__all__']
|
483
536
|
except KeyError:
|
484
537
|
return default
|
538
|
+
|
485
539
|
try:
|
486
540
|
explicit = next(all.assigned_stmts())
|
487
|
-
except InferenceError:
|
541
|
+
except exceptions.InferenceError:
|
488
542
|
return default
|
489
543
|
except AttributeError:
|
490
544
|
# not an assignment node
|
@@ -492,28 +546,34 @@ class Module(LocalsDictNodeNG):
|
|
492
546
|
return default
|
493
547
|
|
494
548
|
# Try our best to detect the exported name.
|
495
|
-
|
549
|
+
inferred = []
|
496
550
|
try:
|
497
551
|
explicit = next(explicit.infer())
|
498
|
-
except InferenceError:
|
552
|
+
except exceptions.InferenceError:
|
499
553
|
return default
|
500
|
-
if not isinstance(explicit, (Tuple, List)):
|
554
|
+
if not isinstance(explicit, (node_classes.Tuple, node_classes.List)):
|
501
555
|
return default
|
502
556
|
|
503
|
-
str_const = lambda node: (isinstance(node, Const) and
|
557
|
+
str_const = lambda node: (isinstance(node, node_classes.Const) and
|
504
558
|
isinstance(node.value, six.string_types))
|
505
559
|
for node in explicit.elts:
|
506
560
|
if str_const(node):
|
507
|
-
|
561
|
+
inferred.append(node.value)
|
508
562
|
else:
|
509
563
|
try:
|
510
|
-
|
511
|
-
except InferenceError:
|
564
|
+
inferred_node = next(node.infer())
|
565
|
+
except exceptions.InferenceError:
|
512
566
|
continue
|
513
|
-
if str_const(
|
514
|
-
|
515
|
-
return
|
567
|
+
if str_const(inferred_node):
|
568
|
+
inferred.append(inferred_node.value)
|
569
|
+
return inferred
|
516
570
|
|
571
|
+
def _public_names(self):
|
572
|
+
"""Get the list of the names which are publicly available in this module."""
|
573
|
+
return [name for name in self.keys() if not name.startswith('_')]
|
574
|
+
|
575
|
+
def bool_value(self):
|
576
|
+
return True
|
517
577
|
|
518
578
|
|
519
579
|
class ComprehensionScope(LocalsDictNodeNG):
|
@@ -523,11 +583,11 @@ class ComprehensionScope(LocalsDictNodeNG):
|
|
523
583
|
scope_lookup = LocalsDictNodeNG._scope_lookup
|
524
584
|
|
525
585
|
|
526
|
-
class
|
586
|
+
class GeneratorExp(ComprehensionScope):
|
527
587
|
_astroid_fields = ('elt', 'generators')
|
528
588
|
|
529
589
|
def __init__(self):
|
530
|
-
self.
|
590
|
+
self._locals = {}
|
531
591
|
self.elt = None
|
532
592
|
self.generators = []
|
533
593
|
|
@@ -536,7 +596,7 @@ class DictComp(ComprehensionScope):
|
|
536
596
|
_astroid_fields = ('key', 'value', 'generators')
|
537
597
|
|
538
598
|
def __init__(self):
|
539
|
-
self.
|
599
|
+
self._locals = {}
|
540
600
|
self.key = None
|
541
601
|
self.value = None
|
542
602
|
self.generators = []
|
@@ -546,97 +606,53 @@ class SetComp(ComprehensionScope):
|
|
546
606
|
_astroid_fields = ('elt', 'generators')
|
547
607
|
|
548
608
|
def __init__(self):
|
549
|
-
self.
|
609
|
+
self._locals = {}
|
550
610
|
self.elt = None
|
551
611
|
self.generators = []
|
552
612
|
|
553
613
|
|
554
|
-
class _ListComp(NodeNG):
|
614
|
+
class _ListComp(bases.NodeNG):
|
555
615
|
"""class representing a ListComp node"""
|
556
616
|
_astroid_fields = ('elt', 'generators')
|
557
617
|
elt = None
|
558
618
|
generators = None
|
559
619
|
|
560
|
-
|
620
|
+
|
621
|
+
if six.PY3:
|
561
622
|
class ListComp(_ListComp, ComprehensionScope):
|
562
623
|
"""class representing a ListComp node"""
|
563
624
|
def __init__(self):
|
564
|
-
self.
|
625
|
+
self._locals = {}
|
565
626
|
else:
|
566
627
|
class ListComp(_ListComp):
|
567
628
|
"""class representing a ListComp node"""
|
568
629
|
|
569
|
-
# Function ###################################################################
|
570
630
|
|
571
631
|
def _infer_decorator_callchain(node):
|
572
632
|
"""Detect decorator call chaining and see if the end result is a
|
573
633
|
static or a classmethod.
|
574
634
|
"""
|
575
|
-
if not isinstance(node,
|
635
|
+
if not isinstance(node, FunctionDef):
|
576
636
|
return
|
577
637
|
if not node.parent:
|
578
638
|
return
|
579
639
|
try:
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
except (StopIteration, InferenceError):
|
585
|
-
|
586
|
-
if isinstance(result, Instance):
|
587
|
-
|
588
|
-
if isinstance(result,
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
def _function_type(self):
|
596
|
-
"""
|
597
|
-
Function type, possible values are:
|
598
|
-
method, function, staticmethod, classmethod.
|
599
|
-
"""
|
600
|
-
# Can't infer that this node is decorated
|
601
|
-
# with a subclass of `classmethod` where `type` is first set,
|
602
|
-
# so do it here.
|
603
|
-
if self.decorators:
|
604
|
-
for node in self.decorators.nodes:
|
605
|
-
if isinstance(node, CallFunc):
|
606
|
-
# Handle the following case:
|
607
|
-
# @some_decorator(arg1, arg2)
|
608
|
-
# def func(...)
|
609
|
-
#
|
610
|
-
try:
|
611
|
-
current = next(node.func.infer())
|
612
|
-
except InferenceError:
|
613
|
-
continue
|
614
|
-
_type = _infer_decorator_callchain(current)
|
615
|
-
if _type is not None:
|
616
|
-
return _type
|
617
|
-
|
618
|
-
try:
|
619
|
-
for infered in node.infer():
|
620
|
-
# Check to see if this returns a static or a class method.
|
621
|
-
_type = _infer_decorator_callchain(infered)
|
622
|
-
if _type is not None:
|
623
|
-
return _type
|
624
|
-
|
625
|
-
if not isinstance(infered, Class):
|
626
|
-
continue
|
627
|
-
for ancestor in infered.ancestors():
|
628
|
-
if not isinstance(ancestor, Class):
|
629
|
-
continue
|
630
|
-
if ancestor.is_subtype_of('%s.classmethod' % BUILTINS):
|
631
|
-
return 'classmethod'
|
632
|
-
elif ancestor.is_subtype_of('%s.staticmethod' % BUILTINS):
|
633
|
-
return 'staticmethod'
|
634
|
-
except InferenceError:
|
635
|
-
pass
|
636
|
-
return self._type
|
640
|
+
# TODO: We don't handle multiple inference results right now,
|
641
|
+
# because there's no flow to reason when the return
|
642
|
+
# is what we are looking for, a static or a class method.
|
643
|
+
result = next(node.infer_call_result(node.parent))
|
644
|
+
except (StopIteration, exceptions.InferenceError):
|
645
|
+
return
|
646
|
+
if isinstance(result, bases.Instance):
|
647
|
+
result = result._proxied
|
648
|
+
if isinstance(result, ClassDef):
|
649
|
+
if result.is_subtype_of('%s.classmethod' % BUILTINS):
|
650
|
+
return 'classmethod'
|
651
|
+
if result.is_subtype_of('%s.staticmethod' % BUILTINS):
|
652
|
+
return 'staticmethod'
|
637
653
|
|
638
654
|
|
639
|
-
class Lambda(
|
655
|
+
class Lambda(mixins.FilterStmtsMixin, LocalsDictNodeNG):
|
640
656
|
_astroid_fields = ('args', 'body',)
|
641
657
|
name = '<lambda>'
|
642
658
|
|
@@ -644,7 +660,7 @@ class Lambda(LocalsDictNodeNG, FilterStmtsMixin):
|
|
644
660
|
type = 'function'
|
645
661
|
|
646
662
|
def __init__(self):
|
647
|
-
self.
|
663
|
+
self._locals = {}
|
648
664
|
self.args = []
|
649
665
|
self.body = []
|
650
666
|
|
@@ -689,9 +705,10 @@ class Lambda(LocalsDictNodeNG, FilterStmtsMixin):
|
|
689
705
|
return frame._scope_lookup(node, name, offset)
|
690
706
|
|
691
707
|
|
692
|
-
|
693
|
-
|
694
|
-
|
708
|
+
|
709
|
+
class FunctionDef(bases.Statement, Lambda):
|
710
|
+
if six.PY3:
|
711
|
+
_astroid_fields = ('decorators', 'args', 'returns', 'body')
|
695
712
|
returns = None
|
696
713
|
else:
|
697
714
|
_astroid_fields = ('decorators', 'args', 'body')
|
@@ -699,32 +716,137 @@ class Function(Statement, Lambda):
|
|
699
716
|
special_attributes = set(('__name__', '__doc__', '__dict__'))
|
700
717
|
is_function = True
|
701
718
|
# attributes below are set by the builder module or by raw factories
|
702
|
-
blockstart_tolineno = None
|
703
719
|
decorators = None
|
704
|
-
_type = "function"
|
705
|
-
type = cachedproperty(_function_type)
|
706
720
|
|
707
721
|
def __init__(self, name, doc):
|
708
|
-
self.
|
722
|
+
self._locals = {}
|
709
723
|
self.args = []
|
710
724
|
self.body = []
|
711
725
|
self.name = name
|
712
726
|
self.doc = doc
|
713
|
-
self.
|
714
|
-
|
727
|
+
self._instance_attrs = {}
|
728
|
+
|
729
|
+
@property
|
730
|
+
def instance_attrs(self):
|
731
|
+
util.attribute_to_function_warning('instance_attrs', 2.0, 'get_attributes')
|
732
|
+
return self._instance_attrs
|
733
|
+
@instance_attrs.setter
|
734
|
+
def instance_attrs(self, _instance_attrs):
|
735
|
+
util.attribute_to_function_warning('instance_attrs', 2.0, 'get_attributes')
|
736
|
+
self._instance_attrs = _instance_attrs
|
737
|
+
@instance_attrs.deleter
|
738
|
+
def instance_attrs(self):
|
739
|
+
util.attribute_to_function_warning('instance_attrs', 2.0, 'get_attributes')
|
740
|
+
del self._instance_attrs
|
741
|
+
|
742
|
+
@decorators_mod.cachedproperty
|
743
|
+
def extra_decorators(self):
|
744
|
+
"""Get the extra decorators that this function can haves
|
745
|
+
Additional decorators are considered when they are used as
|
746
|
+
assignments, as in `method = staticmethod(method)`.
|
747
|
+
The property will return all the callables that are used for
|
748
|
+
decoration.
|
749
|
+
"""
|
750
|
+
frame = self.parent.frame()
|
751
|
+
if not isinstance(frame, ClassDef):
|
752
|
+
return []
|
753
|
+
|
754
|
+
decorators = []
|
755
|
+
for assign in frame.nodes_of_class(node_classes.Assign):
|
756
|
+
if (isinstance(assign.value, node_classes.Call)
|
757
|
+
and isinstance(assign.value.func, node_classes.Name)):
|
758
|
+
for assign_node in assign.targets:
|
759
|
+
if not isinstance(assign_node, node_classes.AssignName):
|
760
|
+
# Support only `name = callable(name)`
|
761
|
+
continue
|
762
|
+
|
763
|
+
if assign_node.name != self.name:
|
764
|
+
# Interested only in the assignment nodes that
|
765
|
+
# decorates the current method.
|
766
|
+
continue
|
767
|
+
try:
|
768
|
+
meth = frame[self.name]
|
769
|
+
except KeyError:
|
770
|
+
continue
|
771
|
+
else:
|
772
|
+
# Must be a function and in the same frame as the
|
773
|
+
# original method.
|
774
|
+
if (isinstance(meth, FunctionDef)
|
775
|
+
and assign_node.frame() == frame):
|
776
|
+
decorators.append(assign.value)
|
777
|
+
return decorators
|
778
|
+
|
779
|
+
@decorators_mod.cachedproperty
|
780
|
+
def type(self):
|
781
|
+
"""Get the function type for this node.
|
782
|
+
|
783
|
+
Possible values are: method, function, staticmethod, classmethod.
|
784
|
+
"""
|
785
|
+
builtin_descriptors = {'classmethod', 'staticmethod'}
|
786
|
+
|
787
|
+
for decorator in self.extra_decorators:
|
788
|
+
if decorator.func.name in builtin_descriptors:
|
789
|
+
return decorator.func.name
|
715
790
|
|
716
|
-
|
791
|
+
frame = self.parent.frame()
|
792
|
+
type_name = 'function'
|
793
|
+
if isinstance(frame, ClassDef):
|
794
|
+
if self.name == '__new__':
|
795
|
+
return 'classmethod'
|
796
|
+
else:
|
797
|
+
type_name = 'method'
|
798
|
+
|
799
|
+
if self.decorators:
|
800
|
+
for node in self.decorators.nodes:
|
801
|
+
if isinstance(node, node_classes.Name):
|
802
|
+
if node.name in builtin_descriptors:
|
803
|
+
return node.name
|
804
|
+
|
805
|
+
if isinstance(node, node_classes.Call):
|
806
|
+
# Handle the following case:
|
807
|
+
# @some_decorator(arg1, arg2)
|
808
|
+
# def func(...)
|
809
|
+
#
|
810
|
+
try:
|
811
|
+
current = next(node.func.infer())
|
812
|
+
except exceptions.InferenceError:
|
813
|
+
continue
|
814
|
+
_type = _infer_decorator_callchain(current)
|
815
|
+
if _type is not None:
|
816
|
+
return _type
|
817
|
+
|
818
|
+
try:
|
819
|
+
for inferred in node.infer():
|
820
|
+
# Check to see if this returns a static or a class method.
|
821
|
+
_type = _infer_decorator_callchain(inferred)
|
822
|
+
if _type is not None:
|
823
|
+
return _type
|
824
|
+
|
825
|
+
if not isinstance(inferred, ClassDef):
|
826
|
+
continue
|
827
|
+
for ancestor in inferred.ancestors():
|
828
|
+
if not isinstance(ancestor, ClassDef):
|
829
|
+
continue
|
830
|
+
if ancestor.is_subtype_of('%s.classmethod' % BUILTINS):
|
831
|
+
return 'classmethod'
|
832
|
+
elif ancestor.is_subtype_of('%s.staticmethod' % BUILTINS):
|
833
|
+
return 'staticmethod'
|
834
|
+
except exceptions.InferenceError:
|
835
|
+
pass
|
836
|
+
return type_name
|
837
|
+
|
838
|
+
@decorators_mod.cachedproperty
|
717
839
|
def fromlineno(self):
|
718
840
|
# lineno is the line number of the first decorator, we want the def
|
719
841
|
# statement lineno
|
720
842
|
lineno = self.lineno
|
721
843
|
if self.decorators is not None:
|
722
844
|
lineno += sum(node.tolineno - node.lineno + 1
|
723
|
-
|
845
|
+
for node in self.decorators.nodes)
|
724
846
|
|
725
847
|
return lineno
|
726
848
|
|
727
|
-
@cachedproperty
|
849
|
+
@decorators_mod.cachedproperty
|
728
850
|
def blockstart_tolineno(self):
|
729
851
|
return self.args.tolineno
|
730
852
|
|
@@ -740,29 +862,41 @@ class Function(Statement, Lambda):
|
|
740
862
|
done by an Instance proxy at inference time.
|
741
863
|
"""
|
742
864
|
if name == '__module__':
|
743
|
-
return [
|
744
|
-
if name in self.
|
745
|
-
return self.
|
865
|
+
return [node_classes.const_factory(self.root().qname())]
|
866
|
+
if name in self._instance_attrs:
|
867
|
+
return self._instance_attrs[name]
|
746
868
|
return std_special_attributes(self, name, False)
|
747
869
|
|
870
|
+
def igetattr(self, name, context=None):
|
871
|
+
"""Inferred getattr, which returns an iterator of inferred statements."""
|
872
|
+
try:
|
873
|
+
return bases._infer_stmts(self.getattr(name, context),
|
874
|
+
context, frame=self)
|
875
|
+
except exceptions.NotFoundError:
|
876
|
+
raise exceptions.InferenceError(name)
|
877
|
+
|
748
878
|
def is_method(self):
|
749
879
|
"""return true if the function node should be considered as a method"""
|
750
|
-
# check we are defined in a
|
880
|
+
# check we are defined in a ClassDef, because this is usually expected
|
751
881
|
# (e.g. pylint...) when is_method() return True
|
752
|
-
return self.type != 'function' and isinstance(self.parent.frame(),
|
882
|
+
return self.type != 'function' and isinstance(self.parent.frame(), ClassDef)
|
753
883
|
|
884
|
+
@decorators_mod.cached
|
754
885
|
def decoratornames(self):
|
755
886
|
"""return a list of decorator qualified names"""
|
756
887
|
result = set()
|
757
888
|
decoratornodes = []
|
758
889
|
if self.decorators is not None:
|
890
|
+
# pylint: disable=unsupported-binary-operation; damn flow control.
|
759
891
|
decoratornodes += self.decorators.nodes
|
760
892
|
decoratornodes += self.extra_decorators
|
761
893
|
for decnode in decoratornodes:
|
762
|
-
|
763
|
-
|
894
|
+
try:
|
895
|
+
for infnode in decnode.infer():
|
896
|
+
result.add(infnode.qname())
|
897
|
+
except exceptions.InferenceError:
|
898
|
+
continue
|
764
899
|
return result
|
765
|
-
decoratornames = cached(decoratornames)
|
766
900
|
|
767
901
|
def is_bound(self):
|
768
902
|
"""return true if the function is bound to an Instance or a class"""
|
@@ -779,34 +913,34 @@ class Function(Statement, Lambda):
|
|
779
913
|
if self.decorators:
|
780
914
|
for node in self.decorators.nodes:
|
781
915
|
try:
|
782
|
-
|
783
|
-
except InferenceError:
|
916
|
+
inferred = next(node.infer())
|
917
|
+
except exceptions.InferenceError:
|
784
918
|
continue
|
785
|
-
if
|
786
|
-
|
919
|
+
if inferred and inferred.qname() in ('abc.abstractproperty',
|
920
|
+
'abc.abstractmethod'):
|
787
921
|
return True
|
788
922
|
|
789
923
|
for child_node in self.body:
|
790
|
-
if isinstance(child_node, Raise):
|
924
|
+
if isinstance(child_node, node_classes.Raise):
|
791
925
|
if child_node.raises_not_implemented():
|
792
926
|
return True
|
793
|
-
|
794
|
-
return True
|
795
|
-
return False
|
927
|
+
return pass_is_abstract and isinstance(child_node, node_classes.Pass)
|
796
928
|
# empty function is the same as function with a single "pass" statement
|
797
929
|
if pass_is_abstract:
|
798
930
|
return True
|
799
931
|
|
800
932
|
def is_generator(self):
|
801
933
|
"""return true if this is a generator function"""
|
802
|
-
|
803
|
-
return next(self.nodes_of_class(
|
804
|
-
skip_klass=(
|
934
|
+
yield_nodes = (node_classes.Yield, node_classes.YieldFrom)
|
935
|
+
return next(self.nodes_of_class(yield_nodes,
|
936
|
+
skip_klass=(FunctionDef, Lambda)), False)
|
805
937
|
|
806
938
|
def infer_call_result(self, caller, context=None):
|
807
939
|
"""infer what a function is returning when called"""
|
808
940
|
if self.is_generator():
|
809
|
-
|
941
|
+
result = bases.Generator()
|
942
|
+
result.parent = self
|
943
|
+
yield result
|
810
944
|
return
|
811
945
|
# This is really a gigantic hack to work around metaclass generators
|
812
946
|
# that return transient class-generating functions. Pylint's AST structure
|
@@ -818,25 +952,29 @@ class Function(Statement, Lambda):
|
|
818
952
|
len(self.args.args) == 1 and
|
819
953
|
self.args.vararg is not None):
|
820
954
|
metaclass = next(caller.args[0].infer(context))
|
821
|
-
if isinstance(metaclass,
|
822
|
-
c =
|
955
|
+
if isinstance(metaclass, ClassDef):
|
956
|
+
c = ClassDef('temporary_class', None)
|
823
957
|
c.hide = True
|
824
958
|
c.parent = self
|
825
|
-
|
826
|
-
c.bases = [base for base in
|
959
|
+
class_bases = [next(b.infer(context)) for b in caller.args[1:]]
|
960
|
+
c.bases = [base for base in class_bases if base != util.YES]
|
827
961
|
c._metaclass = metaclass
|
828
962
|
yield c
|
829
963
|
return
|
830
|
-
returns = self.nodes_of_class(Return, skip_klass=
|
964
|
+
returns = self.nodes_of_class(node_classes.Return, skip_klass=FunctionDef)
|
831
965
|
for returnnode in returns:
|
832
966
|
if returnnode.value is None:
|
833
|
-
yield Const(None)
|
967
|
+
yield node_classes.Const(None)
|
834
968
|
else:
|
835
969
|
try:
|
836
|
-
for
|
837
|
-
yield
|
838
|
-
except InferenceError:
|
839
|
-
yield YES
|
970
|
+
for inferred in returnnode.value.infer(context):
|
971
|
+
yield inferred
|
972
|
+
except exceptions.InferenceError:
|
973
|
+
yield util.YES
|
974
|
+
|
975
|
+
|
976
|
+
class AsyncFunctionDef(FunctionDef):
|
977
|
+
"""Asynchronous function created with the `async` keyword."""
|
840
978
|
|
841
979
|
|
842
980
|
def _rec_get_names(args, names=None):
|
@@ -844,16 +982,13 @@ def _rec_get_names(args, names=None):
|
|
844
982
|
if names is None:
|
845
983
|
names = []
|
846
984
|
for arg in args:
|
847
|
-
if isinstance(arg, Tuple):
|
985
|
+
if isinstance(arg, node_classes.Tuple):
|
848
986
|
_rec_get_names(arg.elts, names)
|
849
987
|
else:
|
850
988
|
names.append(arg.name)
|
851
989
|
return names
|
852
990
|
|
853
991
|
|
854
|
-
# Class ######################################################################
|
855
|
-
|
856
|
-
|
857
992
|
def _is_metaclass(klass, seen=None):
|
858
993
|
""" Return if the given class can be
|
859
994
|
used as a metaclass.
|
@@ -865,30 +1000,31 @@ def _is_metaclass(klass, seen=None):
|
|
865
1000
|
for base in klass.bases:
|
866
1001
|
try:
|
867
1002
|
for baseobj in base.infer():
|
868
|
-
|
1003
|
+
baseobj_name = baseobj.qname()
|
1004
|
+
if baseobj_name in seen:
|
869
1005
|
continue
|
870
1006
|
else:
|
871
|
-
seen.add(
|
872
|
-
if isinstance(baseobj, Instance):
|
1007
|
+
seen.add(baseobj_name)
|
1008
|
+
if isinstance(baseobj, bases.Instance):
|
873
1009
|
# not abstract
|
874
1010
|
return False
|
875
|
-
if baseobj is YES:
|
1011
|
+
if baseobj is util.YES:
|
876
1012
|
continue
|
877
1013
|
if baseobj is klass:
|
878
1014
|
continue
|
879
|
-
if not isinstance(baseobj,
|
1015
|
+
if not isinstance(baseobj, ClassDef):
|
880
1016
|
continue
|
881
1017
|
if baseobj._type == 'metaclass':
|
882
1018
|
return True
|
883
1019
|
if _is_metaclass(baseobj, seen):
|
884
1020
|
return True
|
885
|
-
except InferenceError:
|
1021
|
+
except exceptions.InferenceError:
|
886
1022
|
continue
|
887
1023
|
return False
|
888
1024
|
|
889
1025
|
|
890
1026
|
def _class_type(klass, ancestors=None):
|
891
|
-
"""return a
|
1027
|
+
"""return a ClassDef node type to differ metaclass and exception
|
892
1028
|
from 'regular' classes
|
893
1029
|
"""
|
894
1030
|
# XXX we have to store ancestors in case we have a ancestor loop
|
@@ -896,18 +1032,17 @@ def _class_type(klass, ancestors=None):
|
|
896
1032
|
return klass._type
|
897
1033
|
if _is_metaclass(klass):
|
898
1034
|
klass._type = 'metaclass'
|
899
|
-
elif klass.name.endswith('Interface'):
|
900
|
-
klass._type = 'interface'
|
901
1035
|
elif klass.name.endswith('Exception'):
|
902
1036
|
klass._type = 'exception'
|
903
1037
|
else:
|
904
1038
|
if ancestors is None:
|
905
1039
|
ancestors = set()
|
906
|
-
|
1040
|
+
klass_name = klass.qname()
|
1041
|
+
if klass_name in ancestors:
|
907
1042
|
# XXX we are in loop ancestors, and have found no type
|
908
1043
|
klass._type = 'class'
|
909
1044
|
return 'class'
|
910
|
-
ancestors.add(
|
1045
|
+
ancestors.add(klass_name)
|
911
1046
|
for base in klass.ancestors(recurs=False):
|
912
1047
|
name = _class_type(base, ancestors)
|
913
1048
|
if name != 'class':
|
@@ -921,14 +1056,8 @@ def _class_type(klass, ancestors=None):
|
|
921
1056
|
klass._type = 'class'
|
922
1057
|
return klass._type
|
923
1058
|
|
924
|
-
def _iface_hdlr(iface_node):
|
925
|
-
"""a handler function used by interfaces to handle suspicious
|
926
|
-
interface nodes
|
927
|
-
"""
|
928
|
-
return True
|
929
|
-
|
930
1059
|
|
931
|
-
class
|
1060
|
+
class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, bases.Statement):
|
932
1061
|
|
933
1062
|
# some of the attributes below are set by the builder module or
|
934
1063
|
# by a raw factories
|
@@ -939,26 +1068,38 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
939
1068
|
decorators = None
|
940
1069
|
special_attributes = set(('__name__', '__doc__', '__dict__', '__module__',
|
941
1070
|
'__bases__', '__mro__', '__subclasses__'))
|
942
|
-
blockstart_tolineno = None
|
943
1071
|
|
944
1072
|
_type = None
|
945
1073
|
_metaclass_hack = False
|
946
1074
|
hide = False
|
947
1075
|
type = property(_class_type,
|
948
1076
|
doc="class'type, possible values are 'class' | "
|
949
|
-
"'metaclass' | '
|
1077
|
+
"'metaclass' | 'exception'")
|
950
1078
|
|
951
1079
|
def __init__(self, name, doc):
|
952
|
-
self.
|
953
|
-
self.
|
1080
|
+
self._instance_attrs = {}
|
1081
|
+
self._locals = {}
|
954
1082
|
self.bases = []
|
955
1083
|
self.body = []
|
956
1084
|
self.name = name
|
957
1085
|
self.doc = doc
|
958
1086
|
|
1087
|
+
@property
|
1088
|
+
def instance_attrs(self):
|
1089
|
+
util.attribute_to_function_warning('instance_attrs', 2.0, 'get_attributes')
|
1090
|
+
return self._instance_attrs
|
1091
|
+
@instance_attrs.setter
|
1092
|
+
def instance_attrs(self, _instance_attrs):
|
1093
|
+
util.attribute_to_function_warning('instance_attrs', 2.0, 'get_attributes')
|
1094
|
+
self._instance_attrs = _instance_attrs
|
1095
|
+
@instance_attrs.deleter
|
1096
|
+
def instance_attrs(self):
|
1097
|
+
util.attribute_to_function_warning('instance_attrs', 2.0, 'get_attributes')
|
1098
|
+
del self._instance_attrs
|
1099
|
+
|
959
1100
|
def _newstyle_impl(self, context=None):
|
960
1101
|
if context is None:
|
961
|
-
context = InferenceContext()
|
1102
|
+
context = contextmod.InferenceContext()
|
962
1103
|
if self._newstyle is not None:
|
963
1104
|
return self._newstyle
|
964
1105
|
for base in self.ancestors(recurs=False, context=context):
|
@@ -968,7 +1109,7 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
968
1109
|
klass = self._explicit_metaclass()
|
969
1110
|
# could be any callable, we'd need to infer the result of klass(name,
|
970
1111
|
# bases, dict). punt if it's not a class node.
|
971
|
-
if klass is not None and isinstance(klass,
|
1112
|
+
if klass is not None and isinstance(klass, ClassDef):
|
972
1113
|
self._newstyle = klass._newstyle_impl(context)
|
973
1114
|
if self._newstyle is None:
|
974
1115
|
self._newstyle = False
|
@@ -979,7 +1120,7 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
979
1120
|
doc="boolean indicating if it's a new style class"
|
980
1121
|
"or not")
|
981
1122
|
|
982
|
-
@cachedproperty
|
1123
|
+
@decorators_mod.cachedproperty
|
983
1124
|
def blockstart_tolineno(self):
|
984
1125
|
if self.bases:
|
985
1126
|
return self.bases[-1].tolineno
|
@@ -1011,32 +1152,52 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1011
1152
|
if anc.qname() == type_name:
|
1012
1153
|
return True
|
1013
1154
|
|
1155
|
+
def _infer_type_call(self, caller, context):
|
1156
|
+
name_node = next(caller.args[0].infer(context))
|
1157
|
+
if (isinstance(name_node, node_classes.Const) and
|
1158
|
+
isinstance(name_node.value, six.string_types)):
|
1159
|
+
name = name_node.value
|
1160
|
+
else:
|
1161
|
+
return util.YES
|
1162
|
+
|
1163
|
+
result = ClassDef(name, None)
|
1164
|
+
|
1165
|
+
# Get the bases of the class.
|
1166
|
+
class_bases = next(caller.args[1].infer(context))
|
1167
|
+
if isinstance(class_bases, (node_classes.Tuple, node_classes.List)):
|
1168
|
+
result.bases = class_bases.itered()
|
1169
|
+
else:
|
1170
|
+
# There is currently no AST node that can represent an 'unknown'
|
1171
|
+
# node (YES is not an AST node), therefore we simply return YES here
|
1172
|
+
# although we know at least the name of the class.
|
1173
|
+
return util.YES
|
1174
|
+
|
1175
|
+
# Get the members of the class
|
1176
|
+
try:
|
1177
|
+
members = next(caller.args[2].infer(context))
|
1178
|
+
except exceptions.InferenceError:
|
1179
|
+
members = None
|
1180
|
+
|
1181
|
+
if members and isinstance(members, node_classes.Dict):
|
1182
|
+
for attr, value in members.items:
|
1183
|
+
if (isinstance(attr, node_classes.Const) and
|
1184
|
+
isinstance(attr.value, six.string_types)):
|
1185
|
+
result._locals[attr.value] = [value]
|
1186
|
+
|
1187
|
+
result.parent = caller.parent
|
1188
|
+
return result
|
1189
|
+
|
1014
1190
|
def infer_call_result(self, caller, context=None):
|
1015
1191
|
"""infer what a class is returning when called"""
|
1016
|
-
if self.is_subtype_of('%s.type' % (BUILTINS,), context)
|
1017
|
-
|
1018
|
-
|
1019
|
-
isinstance(name_node.value, six.string_types)):
|
1020
|
-
name = name_node.value
|
1021
|
-
else:
|
1022
|
-
yield YES
|
1023
|
-
return
|
1024
|
-
result = Class(name, None)
|
1025
|
-
bases = next(caller.args[1].infer(context))
|
1026
|
-
if isinstance(bases, (Tuple, List)):
|
1027
|
-
result.bases = bases.itered()
|
1028
|
-
else:
|
1029
|
-
# There is currently no AST node that can represent an 'unknown'
|
1030
|
-
# node (YES is not an AST node), therefore we simply return YES here
|
1031
|
-
# although we know at least the name of the class.
|
1032
|
-
yield YES
|
1033
|
-
return
|
1034
|
-
result.parent = caller.parent
|
1192
|
+
if (self.is_subtype_of('%s.type' % (BUILTINS,), context)
|
1193
|
+
and len(caller.args) == 3):
|
1194
|
+
result = self._infer_type_call(caller, context)
|
1035
1195
|
yield result
|
1036
1196
|
else:
|
1037
|
-
yield Instance(self)
|
1197
|
+
yield bases.Instance(self)
|
1038
1198
|
|
1039
1199
|
def scope_lookup(self, node, name, offset=0):
|
1200
|
+
# pylint: disable=redefined-variable-type
|
1040
1201
|
if any(node == base or base.parent_of(node)
|
1041
1202
|
for base in self.bases):
|
1042
1203
|
# Handle the case where we have either a name
|
@@ -1060,11 +1221,10 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1060
1221
|
frame = self
|
1061
1222
|
return frame._scope_lookup(node, name, offset)
|
1062
1223
|
|
1063
|
-
|
1064
|
-
# in the class definition) XXX bw compat
|
1224
|
+
@property
|
1065
1225
|
def basenames(self):
|
1226
|
+
"""Get the list of parent class names, as they appear in the class definition."""
|
1066
1227
|
return [bnode.as_string() for bnode in self.bases]
|
1067
|
-
basenames = property(basenames)
|
1068
1228
|
|
1069
1229
|
def ancestors(self, recurs=True, context=None):
|
1070
1230
|
"""return an iterator on the node base classes in a prefixed
|
@@ -1078,8 +1238,8 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1078
1238
|
# FIXME: inference make infinite loops possible here
|
1079
1239
|
yielded = set([self])
|
1080
1240
|
if context is None:
|
1081
|
-
context = InferenceContext()
|
1082
|
-
if
|
1241
|
+
context = contextmod.InferenceContext()
|
1242
|
+
if six.PY3:
|
1083
1243
|
if not self.bases and self.qname() != 'builtins.object':
|
1084
1244
|
yield builtin_lookup("object")[1][0]
|
1085
1245
|
return
|
@@ -1088,15 +1248,14 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1088
1248
|
with context.restore_path():
|
1089
1249
|
try:
|
1090
1250
|
for baseobj in stmt.infer(context):
|
1091
|
-
if not isinstance(baseobj,
|
1092
|
-
if isinstance(baseobj, Instance):
|
1251
|
+
if not isinstance(baseobj, ClassDef):
|
1252
|
+
if isinstance(baseobj, bases.Instance):
|
1093
1253
|
baseobj = baseobj._proxied
|
1094
1254
|
else:
|
1095
|
-
# duh ?
|
1096
1255
|
continue
|
1097
1256
|
if not baseobj.hide:
|
1098
1257
|
if baseobj in yielded:
|
1099
|
-
continue
|
1258
|
+
continue
|
1100
1259
|
yielded.add(baseobj)
|
1101
1260
|
yield baseobj
|
1102
1261
|
if recurs:
|
@@ -1106,18 +1265,28 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1106
1265
|
# This class is the ancestor of itself.
|
1107
1266
|
break
|
1108
1267
|
if grandpa in yielded:
|
1109
|
-
continue
|
1268
|
+
continue
|
1110
1269
|
yielded.add(grandpa)
|
1111
1270
|
yield grandpa
|
1112
|
-
except InferenceError:
|
1113
|
-
# XXX log error ?
|
1271
|
+
except exceptions.InferenceError:
|
1114
1272
|
continue
|
1115
1273
|
|
1116
1274
|
def local_attr_ancestors(self, name, context=None):
|
1117
1275
|
"""return an iterator on astroid representation of parent classes
|
1118
1276
|
which have <name> defined in their locals
|
1119
1277
|
"""
|
1120
|
-
for
|
1278
|
+
if self.newstyle and all(n.newstyle for n in self.ancestors(context)):
|
1279
|
+
# Look up in the mro if we can. This will result in the
|
1280
|
+
# attribute being looked up just as Python does it.
|
1281
|
+
try:
|
1282
|
+
ancestors = self.mro(context)[1:]
|
1283
|
+
except exceptions.MroError:
|
1284
|
+
# Fallback to use ancestors, we can't determine
|
1285
|
+
# a sane MRO.
|
1286
|
+
ancestors = self.ancestors(context=context)
|
1287
|
+
else:
|
1288
|
+
ancestors = self.ancestors(context=context)
|
1289
|
+
for astroid in ancestors:
|
1121
1290
|
if name in astroid:
|
1122
1291
|
yield astroid
|
1123
1292
|
|
@@ -1126,12 +1295,13 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1126
1295
|
which have <name> defined in their instance attribute dictionary
|
1127
1296
|
"""
|
1128
1297
|
for astroid in self.ancestors(context=context):
|
1129
|
-
if name in astroid.
|
1298
|
+
if name in astroid._instance_attrs:
|
1130
1299
|
yield astroid
|
1131
1300
|
|
1132
1301
|
def has_base(self, node):
|
1133
1302
|
return node in self.bases
|
1134
1303
|
|
1304
|
+
@remove_nodes(node_classes.DelAttr)
|
1135
1305
|
def local_attr(self, name, context=None):
|
1136
1306
|
"""return the list of assign node associated to name in this class
|
1137
1307
|
locals or in its parents
|
@@ -1141,14 +1311,13 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1141
1311
|
its parent classes
|
1142
1312
|
"""
|
1143
1313
|
try:
|
1144
|
-
return self.
|
1314
|
+
return self._locals[name]
|
1145
1315
|
except KeyError:
|
1146
|
-
# get if from the first parent implementing it if any
|
1147
1316
|
for class_node in self.local_attr_ancestors(name, context):
|
1148
|
-
return class_node.
|
1149
|
-
raise NotFoundError(name)
|
1150
|
-
local_attr = remove_nodes(local_attr, DelAttr)
|
1317
|
+
return class_node._locals[name]
|
1318
|
+
raise exceptions.NotFoundError(name)
|
1151
1319
|
|
1320
|
+
@remove_nodes(node_classes.DelAttr)
|
1152
1321
|
def instance_attr(self, name, context=None):
|
1153
1322
|
"""return the astroid nodes associated to name in this class instance
|
1154
1323
|
attributes dictionary and in its parents
|
@@ -1157,20 +1326,24 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1157
1326
|
if no attribute with this name has been find in this class or
|
1158
1327
|
its parent classes
|
1159
1328
|
"""
|
1160
|
-
# Return a copy, so we don't modify self.
|
1329
|
+
# Return a copy, so we don't modify self._instance_attrs,
|
1161
1330
|
# which could lead to infinite loop.
|
1162
|
-
values = list(self.
|
1331
|
+
values = list(self._instance_attrs.get(name, []))
|
1163
1332
|
# get all values from parents
|
1164
1333
|
for class_node in self.instance_attr_ancestors(name, context):
|
1165
|
-
values += class_node.
|
1334
|
+
values += class_node._instance_attrs[name]
|
1166
1335
|
if not values:
|
1167
|
-
raise NotFoundError(name)
|
1336
|
+
raise exceptions.NotFoundError(name)
|
1168
1337
|
return values
|
1169
|
-
|
1338
|
+
|
1339
|
+
def instantiate_class(self):
|
1340
|
+
"""return Instance of ClassDef node, else return self"""
|
1341
|
+
return bases.Instance(self)
|
1170
1342
|
|
1171
1343
|
def instanciate_class(self):
|
1172
|
-
"""return Instance of
|
1173
|
-
|
1344
|
+
"""return Instance of ClassDef node, else return self"""
|
1345
|
+
util.rename_warning('instanciate_class()', 2.0, 'instantiate_class()')
|
1346
|
+
return self.instantiate_class()
|
1174
1347
|
|
1175
1348
|
def getattr(self, name, context=None):
|
1176
1349
|
"""this method doesn't look in the instance_attrs dictionary since it's
|
@@ -1179,25 +1352,27 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1179
1352
|
It may return a YES object if the attribute has not been actually
|
1180
1353
|
found but a __getattr__ or __getattribute__ method is defined
|
1181
1354
|
"""
|
1182
|
-
values = self.
|
1355
|
+
values = self._locals.get(name, [])
|
1183
1356
|
if name in self.special_attributes:
|
1184
1357
|
if name == '__module__':
|
1185
|
-
return [
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
if name == '__bases__' or (name == '__mro__' and self.newstyle):
|
1191
|
-
node = Tuple()
|
1192
|
-
node.items = self.ancestors(recurs=True, context=context)
|
1358
|
+
return [node_classes.const_factory(self.root().qname())] + values
|
1359
|
+
if name == '__bases__':
|
1360
|
+
node = node_classes.Tuple()
|
1361
|
+
elts = list(self._inferred_bases(context))
|
1362
|
+
node.elts = elts
|
1193
1363
|
return [node] + values
|
1364
|
+
if name == '__mro__' and self.newstyle:
|
1365
|
+
mro = self.mro()
|
1366
|
+
node = node_classes.Tuple()
|
1367
|
+
node.elts = mro
|
1368
|
+
return [node]
|
1194
1369
|
return std_special_attributes(self, name)
|
1195
|
-
# don't modify the list in self.
|
1370
|
+
# don't modify the list in self._locals!
|
1196
1371
|
values = list(values)
|
1197
1372
|
for classnode in self.ancestors(recurs=True, context=context):
|
1198
|
-
values += classnode.
|
1373
|
+
values += classnode._locals.get(name, [])
|
1199
1374
|
if not values:
|
1200
|
-
raise NotFoundError(name)
|
1375
|
+
raise exceptions.NotFoundError(name)
|
1201
1376
|
return values
|
1202
1377
|
|
1203
1378
|
def igetattr(self, name, context=None):
|
@@ -1206,46 +1381,50 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1206
1381
|
"""
|
1207
1382
|
# set lookup name since this is necessary to infer on import nodes for
|
1208
1383
|
# instance
|
1209
|
-
context = copy_context(context)
|
1384
|
+
context = contextmod.copy_context(context)
|
1210
1385
|
context.lookupname = name
|
1211
1386
|
try:
|
1212
|
-
for
|
1213
|
-
|
1387
|
+
for inferred in bases._infer_stmts(self.getattr(name, context),
|
1388
|
+
context, frame=self):
|
1214
1389
|
# yield YES object instead of descriptors when necessary
|
1215
|
-
if not isinstance(
|
1390
|
+
if (not isinstance(inferred, node_classes.Const)
|
1391
|
+
and isinstance(inferred, bases.Instance)):
|
1216
1392
|
try:
|
1217
|
-
|
1218
|
-
except NotFoundError:
|
1219
|
-
yield
|
1393
|
+
inferred._proxied.getattr('__get__', context)
|
1394
|
+
except exceptions.NotFoundError:
|
1395
|
+
yield inferred
|
1220
1396
|
else:
|
1221
|
-
yield YES
|
1397
|
+
yield util.YES
|
1222
1398
|
else:
|
1223
|
-
yield function_to_method(
|
1224
|
-
except NotFoundError:
|
1399
|
+
yield function_to_method(inferred, self)
|
1400
|
+
except exceptions.NotFoundError:
|
1225
1401
|
if not name.startswith('__') and self.has_dynamic_getattr(context):
|
1226
1402
|
# class handle some dynamic attributes, return a YES object
|
1227
|
-
yield YES
|
1403
|
+
yield util.YES
|
1228
1404
|
else:
|
1229
|
-
raise InferenceError(name)
|
1405
|
+
raise exceptions.InferenceError(name)
|
1230
1406
|
|
1231
1407
|
def has_dynamic_getattr(self, context=None):
|
1232
|
-
"""return True if the class has a custom __getattr__ or
|
1233
|
-
__getattribute__ method
|
1234
1408
|
"""
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1409
|
+
Check if the current instance has a custom __getattr__
|
1410
|
+
or a custom __getattribute__.
|
1411
|
+
|
1412
|
+
If any such method is found and it is not from
|
1413
|
+
builtins, nor from an extension module, then the function
|
1414
|
+
will return True.
|
1415
|
+
"""
|
1416
|
+
def _valid_getattr(node):
|
1417
|
+
root = node.root()
|
1418
|
+
return root.name != BUILTINS and getattr(root, 'pure_python', None)
|
1419
|
+
|
1238
1420
|
try:
|
1239
|
-
self.getattr('__getattr__', context)
|
1240
|
-
|
1241
|
-
except NotFoundError:
|
1421
|
+
return _valid_getattr(self.getattr('__getattr__', context)[0])
|
1422
|
+
except exceptions.NotFoundError:
|
1242
1423
|
#if self.newstyle: XXX cause an infinite recursion error
|
1243
1424
|
try:
|
1244
1425
|
getattribute = self.getattr('__getattribute__', context)[0]
|
1245
|
-
|
1246
|
-
|
1247
|
-
return True
|
1248
|
-
except NotFoundError:
|
1426
|
+
return _valid_getattr(getattribute)
|
1427
|
+
except exceptions.NotFoundError:
|
1249
1428
|
pass
|
1250
1429
|
return False
|
1251
1430
|
|
@@ -1254,7 +1433,7 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1254
1433
|
its ancestors
|
1255
1434
|
"""
|
1256
1435
|
done = {}
|
1257
|
-
for astroid in chain(iter((self,)), self.ancestors()):
|
1436
|
+
for astroid in itertools.chain(iter((self,)), self.ancestors()):
|
1258
1437
|
for meth in astroid.mymethods():
|
1259
1438
|
if meth.name in done:
|
1260
1439
|
continue
|
@@ -1264,31 +1443,19 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1264
1443
|
def mymethods(self):
|
1265
1444
|
"""return an iterator on all methods defined in the class"""
|
1266
1445
|
for member in self.values():
|
1267
|
-
if isinstance(member,
|
1446
|
+
if isinstance(member, FunctionDef):
|
1268
1447
|
yield member
|
1269
1448
|
|
1270
|
-
def
|
1271
|
-
"""
|
1272
|
-
|
1449
|
+
def implicit_metaclass(self):
|
1450
|
+
"""Get the implicit metaclass of the current class
|
1451
|
+
|
1452
|
+
For newstyle classes, this will return an instance of builtins.type.
|
1453
|
+
For oldstyle classes, it will simply return None, since there's
|
1454
|
+
no implicit metaclass there.
|
1273
1455
|
"""
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
except NotFoundError:
|
1278
|
-
return
|
1279
|
-
if not herited and not implements.frame() is self:
|
1280
|
-
return
|
1281
|
-
found = set()
|
1282
|
-
missing = False
|
1283
|
-
for iface in unpack_infer(implements):
|
1284
|
-
if iface is YES:
|
1285
|
-
missing = True
|
1286
|
-
continue
|
1287
|
-
if not iface in found and handler_func(iface):
|
1288
|
-
found.add(iface)
|
1289
|
-
yield iface
|
1290
|
-
if missing:
|
1291
|
-
raise InferenceError()
|
1456
|
+
|
1457
|
+
if self.newstyle:
|
1458
|
+
return builtin_lookup('type')[1][0]
|
1292
1459
|
|
1293
1460
|
_metaclass = None
|
1294
1461
|
def _explicit_metaclass(self):
|
@@ -1304,29 +1471,29 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1304
1471
|
for base in self.bases:
|
1305
1472
|
try:
|
1306
1473
|
for baseobj in base.infer():
|
1307
|
-
if isinstance(baseobj,
|
1474
|
+
if isinstance(baseobj, ClassDef) and baseobj.hide:
|
1308
1475
|
self._metaclass = baseobj._metaclass
|
1309
1476
|
self._metaclass_hack = True
|
1310
1477
|
break
|
1311
|
-
except InferenceError:
|
1478
|
+
except exceptions.InferenceError:
|
1312
1479
|
pass
|
1313
1480
|
|
1314
1481
|
if self._metaclass:
|
1315
1482
|
# Expects this from Py3k TreeRebuilder
|
1316
1483
|
try:
|
1317
1484
|
return next(node for node in self._metaclass.infer()
|
1318
|
-
if node is not YES)
|
1319
|
-
except (InferenceError, StopIteration):
|
1485
|
+
if node is not util.YES)
|
1486
|
+
except (exceptions.InferenceError, StopIteration):
|
1320
1487
|
return None
|
1321
|
-
if
|
1488
|
+
if six.PY3:
|
1322
1489
|
return None
|
1323
1490
|
|
1324
|
-
if '__metaclass__' in self.
|
1325
|
-
assignment = self.
|
1491
|
+
if '__metaclass__' in self._locals:
|
1492
|
+
assignment = self._locals['__metaclass__'][-1]
|
1326
1493
|
elif self.bases:
|
1327
1494
|
return None
|
1328
|
-
elif '__metaclass__' in self.root().
|
1329
|
-
assignments = [ass for ass in self.root().
|
1495
|
+
elif '__metaclass__' in self.root()._locals:
|
1496
|
+
assignments = [ass for ass in self.root()._locals['__metaclass__']
|
1330
1497
|
if ass.lineno < self.lineno]
|
1331
1498
|
if not assignments:
|
1332
1499
|
return None
|
@@ -1335,34 +1502,42 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1335
1502
|
return None
|
1336
1503
|
|
1337
1504
|
try:
|
1338
|
-
|
1339
|
-
except InferenceError:
|
1505
|
+
inferred = next(assignment.infer())
|
1506
|
+
except exceptions.InferenceError:
|
1340
1507
|
return
|
1341
|
-
if
|
1508
|
+
if inferred is util.YES: # don't expose this
|
1342
1509
|
return None
|
1343
|
-
return
|
1510
|
+
return inferred
|
1511
|
+
|
1512
|
+
def _find_metaclass(self, seen=None):
|
1513
|
+
if seen is None:
|
1514
|
+
seen = set()
|
1515
|
+
seen.add(self)
|
1516
|
+
|
1517
|
+
klass = self._explicit_metaclass()
|
1518
|
+
if klass is None:
|
1519
|
+
for parent in self.ancestors():
|
1520
|
+
if parent not in seen:
|
1521
|
+
klass = parent._find_metaclass(seen)
|
1522
|
+
if klass is not None:
|
1523
|
+
break
|
1524
|
+
return klass
|
1344
1525
|
|
1345
1526
|
def metaclass(self):
|
1346
|
-
"""
|
1527
|
+
"""Return the metaclass of this class.
|
1347
1528
|
|
1348
1529
|
If this class does not define explicitly a metaclass,
|
1349
1530
|
then the first defined metaclass in ancestors will be used
|
1350
1531
|
instead.
|
1351
1532
|
"""
|
1352
|
-
|
1353
|
-
if klass is None:
|
1354
|
-
for parent in self.ancestors():
|
1355
|
-
klass = parent.metaclass()
|
1356
|
-
if klass is not None:
|
1357
|
-
break
|
1358
|
-
return klass
|
1533
|
+
return self._find_metaclass()
|
1359
1534
|
|
1360
1535
|
def has_metaclass_hack(self):
|
1361
1536
|
return self._metaclass_hack
|
1362
1537
|
|
1363
1538
|
def _islots(self):
|
1364
1539
|
""" Return an iterator with the inferred slots. """
|
1365
|
-
if '__slots__' not in self.
|
1540
|
+
if '__slots__' not in self._locals:
|
1366
1541
|
return
|
1367
1542
|
for slots in self.igetattr('__slots__'):
|
1368
1543
|
# check if __slots__ is a valid type
|
@@ -1370,12 +1545,12 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1370
1545
|
try:
|
1371
1546
|
slots.getattr(meth)
|
1372
1547
|
break
|
1373
|
-
except NotFoundError:
|
1548
|
+
except exceptions.NotFoundError:
|
1374
1549
|
continue
|
1375
1550
|
else:
|
1376
1551
|
continue
|
1377
1552
|
|
1378
|
-
if isinstance(slots, Const):
|
1553
|
+
if isinstance(slots, node_classes.Const):
|
1379
1554
|
# a string. Ignore the following checks,
|
1380
1555
|
# but yield the node, only if it has a value
|
1381
1556
|
if slots.value:
|
@@ -1385,30 +1560,50 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1385
1560
|
# we can't obtain the values, maybe a .deque?
|
1386
1561
|
continue
|
1387
1562
|
|
1388
|
-
if isinstance(slots, Dict):
|
1563
|
+
if isinstance(slots, node_classes.Dict):
|
1389
1564
|
values = [item[0] for item in slots.items]
|
1390
1565
|
else:
|
1391
1566
|
values = slots.itered()
|
1392
|
-
if values is YES:
|
1567
|
+
if values is util.YES:
|
1393
1568
|
continue
|
1569
|
+
if not values:
|
1570
|
+
# Stop the iteration, because the class
|
1571
|
+
# has an empty list of slots.
|
1572
|
+
raise StopIteration(values)
|
1394
1573
|
|
1395
1574
|
for elt in values:
|
1396
1575
|
try:
|
1397
|
-
for
|
1398
|
-
if
|
1576
|
+
for inferred in elt.infer():
|
1577
|
+
if inferred is util.YES:
|
1399
1578
|
continue
|
1400
|
-
if (not isinstance(
|
1401
|
-
not isinstance(
|
1579
|
+
if (not isinstance(inferred, node_classes.Const) or
|
1580
|
+
not isinstance(inferred.value,
|
1402
1581
|
six.string_types)):
|
1403
1582
|
continue
|
1404
|
-
if not
|
1583
|
+
if not inferred.value:
|
1405
1584
|
continue
|
1406
|
-
yield
|
1407
|
-
except InferenceError:
|
1585
|
+
yield inferred
|
1586
|
+
except exceptions.InferenceError:
|
1408
1587
|
continue
|
1409
1588
|
|
1589
|
+
def _slots(self):
|
1590
|
+
if not self.newstyle:
|
1591
|
+
raise NotImplementedError(
|
1592
|
+
"The concept of slots is undefined for old-style classes.")
|
1593
|
+
|
1594
|
+
slots = self._islots()
|
1595
|
+
try:
|
1596
|
+
first = next(slots)
|
1597
|
+
except StopIteration as exc:
|
1598
|
+
# The class doesn't have a __slots__ definition or empty slots.
|
1599
|
+
if exc.args and exc.args[0] not in ('', None):
|
1600
|
+
return exc.args[0]
|
1601
|
+
return None
|
1602
|
+
# pylint: disable=unsupported-binary-operation; false positive
|
1603
|
+
return [first] + list(slots)
|
1604
|
+
|
1410
1605
|
# Cached, because inferring them all the time is expensive
|
1411
|
-
@cached
|
1606
|
+
@decorators_mod.cached
|
1412
1607
|
def slots(self):
|
1413
1608
|
"""Get all the slots for this node.
|
1414
1609
|
|
@@ -1417,19 +1612,30 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1417
1612
|
Also, it will return None in the case the slots weren't inferred.
|
1418
1613
|
Otherwise, it will return a list of slot names.
|
1419
1614
|
"""
|
1615
|
+
def grouped_slots():
|
1616
|
+
# Not interested in object, since it can't have slots.
|
1617
|
+
for cls in self.mro()[:-1]:
|
1618
|
+
try:
|
1619
|
+
cls_slots = cls._slots()
|
1620
|
+
except NotImplementedError:
|
1621
|
+
continue
|
1622
|
+
if cls_slots is not None:
|
1623
|
+
for slot in cls_slots:
|
1624
|
+
yield slot
|
1625
|
+
else:
|
1626
|
+
yield None
|
1627
|
+
|
1420
1628
|
if not self.newstyle:
|
1421
1629
|
raise NotImplementedError(
|
1422
1630
|
"The concept of slots is undefined for old-style classes.")
|
1423
1631
|
|
1424
|
-
slots =
|
1425
|
-
|
1426
|
-
first = next(slots)
|
1427
|
-
except StopIteration:
|
1428
|
-
# The class doesn't have a __slots__ definition.
|
1632
|
+
slots = list(grouped_slots())
|
1633
|
+
if not all(slot is not None for slot in slots):
|
1429
1634
|
return None
|
1430
|
-
return [first] + list(slots)
|
1431
1635
|
|
1432
|
-
|
1636
|
+
return sorted(slots, key=lambda item: item.value)
|
1637
|
+
|
1638
|
+
def _inferred_bases(self, context=None):
|
1433
1639
|
# TODO(cpopa): really similar with .ancestors,
|
1434
1640
|
# but the difference is when one base is inferred,
|
1435
1641
|
# only the first object is wanted. That's because
|
@@ -1445,8 +1651,8 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1445
1651
|
# only in SomeClass.
|
1446
1652
|
|
1447
1653
|
if context is None:
|
1448
|
-
context = InferenceContext()
|
1449
|
-
if
|
1654
|
+
context = contextmod.InferenceContext()
|
1655
|
+
if six.PY3:
|
1450
1656
|
if not self.bases and self.qname() != 'builtins.object':
|
1451
1657
|
yield builtin_lookup("object")[1][0]
|
1452
1658
|
return
|
@@ -1454,15 +1660,17 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1454
1660
|
for stmt in self.bases:
|
1455
1661
|
try:
|
1456
1662
|
baseobj = next(stmt.infer(context=context))
|
1457
|
-
except InferenceError:
|
1458
|
-
# XXX log error ?
|
1663
|
+
except exceptions.InferenceError:
|
1459
1664
|
continue
|
1460
|
-
if isinstance(baseobj, Instance):
|
1665
|
+
if isinstance(baseobj, bases.Instance):
|
1461
1666
|
baseobj = baseobj._proxied
|
1462
|
-
if not isinstance(baseobj,
|
1667
|
+
if not isinstance(baseobj, ClassDef):
|
1463
1668
|
continue
|
1464
1669
|
if not baseobj.hide:
|
1465
1670
|
yield baseobj
|
1671
|
+
else:
|
1672
|
+
for base in baseobj.bases:
|
1673
|
+
yield base
|
1466
1674
|
|
1467
1675
|
def mro(self, context=None):
|
1468
1676
|
"""Get the method resolution order, using C3 linearization.
|
@@ -1476,9 +1684,33 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
|
|
1476
1684
|
"Could not obtain mro for old-style classes.")
|
1477
1685
|
|
1478
1686
|
bases = list(self._inferred_bases(context=context))
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1687
|
+
bases_mro = []
|
1688
|
+
for base in bases:
|
1689
|
+
try:
|
1690
|
+
mro = base.mro(context=context)
|
1691
|
+
bases_mro.append(mro)
|
1692
|
+
except NotImplementedError:
|
1693
|
+
# Some classes have in their ancestors both newstyle and
|
1694
|
+
# old style classes. For these we can't retrieve the .mro,
|
1695
|
+
# although in Python it's possible, since the class we are
|
1696
|
+
# currently working is in fact new style.
|
1697
|
+
# So, we fallback to ancestors here.
|
1698
|
+
ancestors = list(base.ancestors(context=context))
|
1699
|
+
bases_mro.append(ancestors)
|
1700
|
+
|
1701
|
+
unmerged_mro = ([[self]] + bases_mro + [bases])
|
1483
1702
|
_verify_duplicates_mro(unmerged_mro)
|
1484
1703
|
return _c3_merge(unmerged_mro)
|
1704
|
+
|
1705
|
+
def get_locals(node):
|
1706
|
+
'''Stub function for forwards compatibility.'''
|
1707
|
+
return node._locals
|
1708
|
+
|
1709
|
+
def get_attributes(node):
|
1710
|
+
'''Stub function for forwards compatibility.'''
|
1711
|
+
return node._instance_attrs
|
1712
|
+
|
1713
|
+
# Backwards-compatibility aliases
|
1714
|
+
Class = node_classes.proxy_alias('Class', ClassDef)
|
1715
|
+
Function = node_classes.proxy_alias('Function', FunctionDef)
|
1716
|
+
GenExpr = node_classes.proxy_alias('GenExpr', GeneratorExp)
|