libv8 7.3.492.27.1 → 8.4.255.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +11 -14
- data/CHANGELOG.md +10 -0
- data/README.md +10 -11
- data/Rakefile +30 -36
- data/ext/libv8/builder.rb +1 -1
- data/lib/libv8/version.rb +1 -1
- data/libv8.gemspec +1 -3
- data/vendor/depot_tools/{cipd.ps1 → .cipd_impl.ps1} +0 -0
- data/vendor/depot_tools/.gitattributes +1 -1
- data/vendor/depot_tools/.gitignore +7 -2
- data/vendor/depot_tools/.style.yapf +3 -1
- data/vendor/depot_tools/.vpython +55 -0
- data/vendor/depot_tools/.vpython3 +23 -0
- data/vendor/depot_tools/CROS_OWNERS +3 -1
- data/vendor/depot_tools/GOMA_OWNERS +9 -0
- data/vendor/depot_tools/LUCI_OWNERS +5 -0
- data/vendor/depot_tools/OWNERS +21 -6
- data/vendor/depot_tools/PRESUBMIT.py +35 -18
- data/vendor/depot_tools/README.git-cl.md +0 -14
- data/vendor/depot_tools/README.md +1 -1
- data/vendor/depot_tools/WATCHLISTS +2 -2
- data/vendor/depot_tools/auth.py +60 -772
- data/vendor/depot_tools/autoninja +12 -6
- data/vendor/depot_tools/autoninja.bat +14 -6
- data/vendor/depot_tools/autoninja.py +64 -27
- data/vendor/depot_tools/bb +1 -1
- data/vendor/depot_tools/bootstrap/{win/README.md → README.md} +28 -14
- data/vendor/depot_tools/bootstrap/{win/win_tools.py → bootstrap.py} +60 -43
- data/vendor/depot_tools/bootstrap/{win/git-bash.template.sh → git-bash.template.sh} +1 -1
- data/vendor/depot_tools/bootstrap/{win/git.template.bat → git.template.bat} +0 -0
- data/vendor/depot_tools/bootstrap/manifest.txt +27 -0
- data/vendor/depot_tools/bootstrap/manifest_bleeding_edge.txt +27 -0
- data/vendor/depot_tools/bootstrap/{win/profile.d.python.sh → profile.d.python.sh} +0 -0
- data/vendor/depot_tools/bootstrap/{win/python27.bleeding_edge.bat → python27.bat} +0 -0
- data/vendor/depot_tools/bootstrap/{win/python27.new.bat → python3.bat} +3 -3
- data/vendor/depot_tools/bootstrap/{win/win_tools.bat → win_tools.bat} +21 -16
- data/vendor/depot_tools/bootstrap_python3 +35 -0
- data/vendor/depot_tools/cbuildbot +1 -1
- data/vendor/depot_tools/chrome_set_ver +1 -1
- data/vendor/depot_tools/cipd +43 -39
- data/vendor/depot_tools/cipd.bat +2 -2
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_client_version.digests +15 -14
- data/vendor/depot_tools/cipd_manifest.txt +31 -8
- data/vendor/depot_tools/cipd_manifest.versions +278 -158
- data/vendor/depot_tools/cit.py +9 -7
- data/vendor/depot_tools/clang_format.py +4 -1
- data/vendor/depot_tools/clang_format_merge_driver.py +10 -8
- data/vendor/depot_tools/compile_single_file.py +7 -2
- data/vendor/depot_tools/cpplint.py +51 -45
- data/vendor/depot_tools/cros +87 -0
- data/vendor/depot_tools/cros_sdk +1 -1
- data/vendor/depot_tools/crosjobs +13 -0
- data/vendor/depot_tools/detect_host_arch.py +0 -1
- data/vendor/depot_tools/dirmd +12 -0
- data/vendor/depot_tools/dirmd.bat +7 -0
- data/vendor/depot_tools/download_from_google_storage.py +47 -27
- data/vendor/depot_tools/ensure_bootstrap +14 -0
- data/vendor/depot_tools/fetch +14 -1
- data/vendor/depot_tools/fetch.bat +14 -1
- data/vendor/depot_tools/fetch.py +5 -7
- data/vendor/depot_tools/fetch_configs/chromium.py +6 -4
- data/vendor/depot_tools/fetch_configs/devtools-frontend.py +44 -0
- data/vendor/depot_tools/fetch_configs/ios_internal.py +10 -19
- data/vendor/depot_tools/fix_encoding.py +19 -5
- data/vendor/depot_tools/gclient +28 -12
- data/vendor/depot_tools/gclient-new-workdir.py +2 -0
- data/vendor/depot_tools/gclient.bat +18 -1
- data/vendor/depot_tools/gclient.py +160 -119
- data/vendor/depot_tools/gclient_eval.py +119 -107
- data/vendor/depot_tools/gclient_paths.py +67 -57
- data/vendor/depot_tools/gclient_scm.py +181 -159
- data/vendor/depot_tools/gclient_utils.py +177 -124
- data/vendor/depot_tools/gerrit_client.py +21 -13
- data/vendor/depot_tools/gerrit_util.py +188 -228
- data/vendor/depot_tools/git-cache +1 -1
- data/vendor/depot_tools/git-cl +1 -1
- data/vendor/depot_tools/git-drover +1 -1
- data/vendor/depot_tools/git-find-releases +1 -1
- data/vendor/depot_tools/git-footers +1 -1
- data/vendor/depot_tools/git-freeze +1 -1
- data/vendor/depot_tools/git-hyper-blame +1 -1
- data/vendor/depot_tools/git-map +1 -1
- data/vendor/depot_tools/git-map-branches +1 -1
- data/vendor/depot_tools/git-mark-merge-base +1 -1
- data/vendor/depot_tools/git-nav-downstream +1 -1
- data/vendor/depot_tools/git-new-branch +1 -1
- data/vendor/depot_tools/git-number +1 -1
- data/vendor/depot_tools/git-rebase-update +1 -1
- data/vendor/depot_tools/git-rename-branch +1 -1
- data/vendor/depot_tools/git-reparent-branch +1 -1
- data/vendor/depot_tools/git-retry +1 -1
- data/vendor/depot_tools/git-squash-branch +1 -1
- data/vendor/depot_tools/git-thaw +1 -1
- data/vendor/depot_tools/git-upstream-diff +1 -1
- data/vendor/depot_tools/git_cache.py +255 -360
- data/vendor/depot_tools/git_cl.py +1562 -2059
- data/vendor/depot_tools/git_cl_completion.sh +16 -2
- data/vendor/depot_tools/git_common.py +77 -32
- data/vendor/depot_tools/git_drover.py +17 -8
- data/vendor/depot_tools/git_find_releases.py +11 -9
- data/vendor/depot_tools/git_footers.py +13 -9
- data/vendor/depot_tools/git_freezer.py +3 -1
- data/vendor/depot_tools/git_hyper_blame.py +25 -32
- data/vendor/depot_tools/git_map.py +115 -93
- data/vendor/depot_tools/git_map_branches.py +11 -10
- data/vendor/depot_tools/git_mark_merge_base.py +8 -6
- data/vendor/depot_tools/git_nav_downstream.py +9 -6
- data/vendor/depot_tools/git_new_branch.py +39 -33
- data/vendor/depot_tools/git_number.py +28 -17
- data/vendor/depot_tools/git_rebase_update.py +50 -49
- data/vendor/depot_tools/git_rename_branch.py +2 -2
- data/vendor/depot_tools/git_reparent_branch.py +8 -6
- data/vendor/depot_tools/git_upstream_diff.py +4 -2
- data/vendor/depot_tools/gn.py +6 -4
- data/vendor/depot_tools/goma_auth +12 -0
- data/vendor/depot_tools/goma_auth.bat +8 -0
- data/vendor/depot_tools/goma_ctl +12 -0
- data/vendor/depot_tools/goma_ctl.bat +8 -0
- data/vendor/depot_tools/gsutil.py +5 -2
- data/vendor/depot_tools/gsutil.py.bat +8 -0
- data/vendor/depot_tools/gsutil.vpython +3 -1
- data/vendor/depot_tools/infra/config/OWNERS +2 -2
- data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
- data/vendor/depot_tools/led +1 -1
- data/vendor/depot_tools/lockfile.py +116 -0
- data/vendor/depot_tools/luci-auth +1 -1
- data/vendor/depot_tools/lucicfg +1 -1
- data/vendor/depot_tools/mac_toolchain +1 -1
- data/vendor/depot_tools/man/html/depot_tools.html +1 -1
- data/vendor/depot_tools/man/html/depot_tools_tutorial.html +31 -25
- data/vendor/depot_tools/man/html/git-cl.html +1 -1
- data/vendor/depot_tools/man/html/git-drover.html +18 -18
- data/vendor/depot_tools/man/html/git-footers.html +1 -1
- data/vendor/depot_tools/man/html/git-freeze.html +3 -3
- data/vendor/depot_tools/man/html/git-hyper-blame.html +1 -1
- data/vendor/depot_tools/man/html/git-map-branches.html +2 -2
- data/vendor/depot_tools/man/html/git-map.html +1 -1
- data/vendor/depot_tools/man/html/git-mark-merge-base.html +1 -1
- data/vendor/depot_tools/man/html/git-nav-downstream.html +3 -3
- data/vendor/depot_tools/man/html/git-nav-upstream.html +12 -6
- data/vendor/depot_tools/man/html/git-new-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-rebase-update.html +20 -1
- data/vendor/depot_tools/man/html/git-rename-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-reparent-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-retry.html +1 -1
- data/vendor/depot_tools/man/html/git-squash-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-thaw.html +1 -1
- data/vendor/depot_tools/man/html/git-upstream-diff.html +10 -6
- data/vendor/depot_tools/man/man1/git-cl.1 +4 -4
- data/vendor/depot_tools/man/man1/git-drover.1 +21 -21
- data/vendor/depot_tools/man/man1/git-footers.1 +4 -4
- data/vendor/depot_tools/man/man1/git-freeze.1 +6 -6
- data/vendor/depot_tools/man/man1/git-hyper-blame.1 +4 -4
- data/vendor/depot_tools/man/man1/git-map-branches.1 +4 -4
- data/vendor/depot_tools/man/man1/git-map.1 +4 -4
- data/vendor/depot_tools/man/man1/git-mark-merge-base.1 +4 -4
- data/vendor/depot_tools/man/man1/git-nav-downstream.1 +6 -6
- data/vendor/depot_tools/man/man1/git-nav-upstream.1 +15 -9
- data/vendor/depot_tools/man/man1/git-new-branch.1 +3 -3
- data/vendor/depot_tools/man/man1/git-rebase-update.1 +14 -4
- data/vendor/depot_tools/man/man1/git-rename-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-reparent-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-retry.1 +4 -4
- data/vendor/depot_tools/man/man1/git-squash-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-thaw.1 +4 -4
- data/vendor/depot_tools/man/man1/git-upstream-diff.1 +7 -13
- data/vendor/depot_tools/man/man7/depot_tools.7 +4 -4
- data/vendor/depot_tools/man/man7/depot_tools_tutorial.7 +31 -25
- data/vendor/depot_tools/man/src/common_demo_functions.sh +2 -2
- data/vendor/depot_tools/man/src/depot_tools_tutorial.txt +3 -3
- data/vendor/depot_tools/man/src/filter_demo_output.py +4 -2
- data/vendor/depot_tools/man/src/git-new-branch.txt +2 -1
- data/vendor/depot_tools/man/src/git-rebase-update.txt +8 -1
- data/vendor/depot_tools/metrics.README.md +8 -5
- data/vendor/depot_tools/metrics.py +7 -6
- data/vendor/depot_tools/metrics_utils.py +4 -14
- data/vendor/depot_tools/my_activity.py +85 -251
- data/vendor/depot_tools/ninja +1 -0
- data/vendor/depot_tools/ninja-mac +0 -0
- data/vendor/depot_tools/ninjalog_uploader.py +146 -145
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +69 -60
- data/vendor/depot_tools/owners.py +156 -43
- data/vendor/depot_tools/owners_finder.py +28 -14
- data/vendor/depot_tools/post_build_ninja_summary.py +76 -48
- data/vendor/depot_tools/presubmit_canned_checks.py +293 -106
- data/vendor/depot_tools/presubmit_support.py +527 -333
- data/vendor/depot_tools/prpc +1 -1
- data/vendor/depot_tools/pylint +2 -12
- data/vendor/depot_tools/pylint-1.5 +78 -0
- data/vendor/depot_tools/pylint-1.6 +78 -0
- data/vendor/depot_tools/pylint-1.7 +78 -0
- data/vendor/depot_tools/pylint-1.8 +78 -0
- data/vendor/depot_tools/pylint-1.9 +78 -0
- data/vendor/depot_tools/{depot-tools-auth.bat → pylint.bat} +2 -2
- data/vendor/depot_tools/pylint_main.py +45 -0
- data/vendor/depot_tools/pylintrc +14 -1
- data/vendor/depot_tools/python-bin/python3 +7 -0
- data/vendor/depot_tools/python_runner.sh +13 -8
- data/vendor/depot_tools/rdb +12 -0
- data/vendor/depot_tools/rdb.bat +7 -0
- data/vendor/depot_tools/recipes/OWNERS +0 -1
- data/vendor/depot_tools/recipes/README.recipes.md +218 -151
- data/vendor/depot_tools/recipes/recipe_modules/OWNERS +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +17 -16
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +127 -78
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +19 -4
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +18 -3
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +19 -4
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +28 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/input_commit_with_id_without_repo.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/multiple_patch_refs.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{with_manifest_name.json → no_cp_checkout_HEAD.json} +25 -15
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_a_branch_head.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_a_specific_commit.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_master.json +65 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/refs.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/resolve_chromium_fixed_version.json +117 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +17 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +41 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +24 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +38 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +36 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +35 -10
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +0 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +29 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +95 -22
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +187 -114
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py +42 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/__init__.py +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +2 -4
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +26 -6
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +23 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +23 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/cipd/test_api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +4 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +4 -2
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +3 -1
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +4 -2
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +82 -13
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +23 -11
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +3 -4
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +3 -6
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +3 -4
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +7 -7
- data/vendor/depot_tools/recipes/recipe_modules/gclient/resources/diff_deps.py +16 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/test_api.py +4 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/basic.json +55 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/dont have revision yet.json +84 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/no change, exception.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/windows.json +55 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.py +88 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +9 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/sync_failure.py +24 -0
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +7 -12
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +0 -2
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +9 -17
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +3 -13
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +4 -12
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +2 -10
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +1 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +1 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +0 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +3 -10
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +3 -11
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +3 -13
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +2 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +0 -5
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/__init__.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +7 -13
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +21 -16
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.py +1 -2
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +2 -2
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +23 -8
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +52 -1
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.py +15 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +32 -8
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/ancient_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/automatic_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/explicit_version.json +83 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +5 -4
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +21 -2
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +20 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +235 -3
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +13 -5
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.py +5 -1
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/properties.proto +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/test_api.py +19 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/tests/execute.py +247 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/tests/prepare.py +49 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +33 -45
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +64 -21
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +64 -21
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +1 -22
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +1 -22
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +5 -32
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_fetch_ref_timeout.py +29 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_owner.expected/basic.json +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_owner.py +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_target_ref.py +32 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +2 -1
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +1 -6
- data/vendor/depot_tools/recipes/recipes.py +49 -28
- data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +11 -6
- data/vendor/depot_tools/repo +698 -540
- data/vendor/depot_tools/roll-dep +14 -1
- data/vendor/depot_tools/roll-dep.bat +10 -1
- data/vendor/depot_tools/roll_dep.py +15 -10
- data/vendor/depot_tools/scm.py +95 -75
- data/vendor/depot_tools/setup_color.py +36 -2
- data/vendor/depot_tools/split_cl.py +44 -32
- data/vendor/depot_tools/subcommand.py +6 -6
- data/vendor/depot_tools/subprocess2.py +38 -322
- data/vendor/depot_tools/third_party/colorama/LICENSE.txt +0 -1
- data/vendor/depot_tools/third_party/colorama/README.chromium +4 -5
- data/vendor/depot_tools/third_party/colorama/README.rst +346 -0
- data/vendor/depot_tools/third_party/colorama/__init__.py +3 -4
- data/vendor/depot_tools/third_party/colorama/ansi.py +82 -30
- data/vendor/depot_tools/third_party/colorama/ansitowin32.py +105 -37
- data/vendor/depot_tools/third_party/colorama/initialise.py +39 -15
- data/vendor/depot_tools/third_party/colorama/win32.py +46 -28
- data/vendor/depot_tools/third_party/colorama/winterm.py +80 -31
- data/vendor/depot_tools/update_depot_tools +18 -8
- data/vendor/depot_tools/update_depot_tools.bat +19 -15
- data/vendor/depot_tools/upload_metrics.py +7 -6
- data/vendor/depot_tools/upload_to_google_storage.py +23 -16
- data/vendor/depot_tools/vpython +4 -4
- data/vendor/depot_tools/vpython.bat +1 -1
- data/vendor/depot_tools/vpython3 +55 -0
- data/vendor/depot_tools/vpython3.bat +12 -0
- data/vendor/depot_tools/watchlists.py +14 -11
- data/vendor/depot_tools/weekly +4 -2
- data/vendor/depot_tools/win32imports.py +61 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +49 -41
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +142 -149
- data/vendor/depot_tools/wtf +5 -3
- data/vendor/depot_tools/yapf +5 -1
- metadata +68 -343
- data/vendor/depot_tools/README.testing +0 -23
- data/vendor/depot_tools/annotated_gclient.py +0 -89
- data/vendor/depot_tools/appengine_mapper.py +0 -23
- data/vendor/depot_tools/bootstrap/win/manifest.txt +0 -20
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +0 -20
- data/vendor/depot_tools/bootstrap/win/pylint.new.bat +0 -7
- data/vendor/depot_tools/buildbucket.py +0 -186
- data/vendor/depot_tools/checkout.py +0 -431
- data/vendor/depot_tools/cros +0 -1
- data/vendor/depot_tools/dart_format.py +0 -58
- data/vendor/depot_tools/depot-tools-auth +0 -8
- data/vendor/depot_tools/depot-tools-auth.py +0 -102
- data/vendor/depot_tools/my_reviews.py +0 -396
- data/vendor/depot_tools/patch.py +0 -548
- data/vendor/depot_tools/pylint.py +0 -30
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +0 -239
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +0 -222
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/__init__.py +0 -4
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/api.py +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +0 -15
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.py +0 -33
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +0 -66
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +0 -11
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +0 -45
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +0 -45
- data/vendor/depot_tools/rietveld.py +0 -779
- data/vendor/depot_tools/roll-dep-svn +0 -8
- data/vendor/depot_tools/roll-dep-svn.bat +0 -12
- data/vendor/depot_tools/roll_dep_svn.py +0 -430
- data/vendor/depot_tools/support/chromite_wrapper +0 -96
- data/vendor/depot_tools/third_party/boto/LICENSE +0 -18
- data/vendor/depot_tools/third_party/boto/README.chromium +0 -43
- data/vendor/depot_tools/third_party/boto/README.rst +0 -163
- data/vendor/depot_tools/third_party/boto/__init__.py +0 -793
- data/vendor/depot_tools/third_party/boto/auth.py +0 -682
- data/vendor/depot_tools/third_party/boto/auth_handler.py +0 -58
- data/vendor/depot_tools/third_party/boto/cacerts/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/cacerts/cacerts.txt +0 -2183
- data/vendor/depot_tools/third_party/boto/compat.py +0 -28
- data/vendor/depot_tools/third_party/boto/connection.py +0 -1081
- data/vendor/depot_tools/third_party/boto/contrib/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/contrib/ymlmessage.py +0 -52
- data/vendor/depot_tools/third_party/boto/core/README +0 -58
- data/vendor/depot_tools/third_party/boto/core/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/core/auth.py +0 -78
- data/vendor/depot_tools/third_party/boto/core/credentials.py +0 -154
- data/vendor/depot_tools/third_party/boto/core/dictresponse.py +0 -178
- data/vendor/depot_tools/third_party/boto/core/service.py +0 -67
- data/vendor/depot_tools/third_party/boto/datapipeline/__init__.py +0 -0
- data/vendor/depot_tools/third_party/boto/datapipeline/exceptions.py +0 -42
- data/vendor/depot_tools/third_party/boto/datapipeline/layer1.py +0 -546
- data/vendor/depot_tools/third_party/boto/ecs/__init__.py +0 -90
- data/vendor/depot_tools/third_party/boto/ecs/item.py +0 -153
- data/vendor/depot_tools/third_party/boto/exception.py +0 -476
- data/vendor/depot_tools/third_party/boto/file/README +0 -49
- data/vendor/depot_tools/third_party/boto/file/__init__.py +0 -28
- data/vendor/depot_tools/third_party/boto/file/bucket.py +0 -112
- data/vendor/depot_tools/third_party/boto/file/connection.py +0 -33
- data/vendor/depot_tools/third_party/boto/file/key.py +0 -199
- data/vendor/depot_tools/third_party/boto/file/simpleresultset.py +0 -30
- data/vendor/depot_tools/third_party/boto/fps/__init__.py +0 -21
- data/vendor/depot_tools/third_party/boto/fps/connection.py +0 -369
- data/vendor/depot_tools/third_party/boto/fps/exception.py +0 -344
- data/vendor/depot_tools/third_party/boto/fps/response.py +0 -175
- data/vendor/depot_tools/third_party/boto/gs/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/gs/acl.py +0 -304
- data/vendor/depot_tools/third_party/boto/gs/bucket.py +0 -870
- data/vendor/depot_tools/third_party/boto/gs/bucketlistresultset.py +0 -64
- data/vendor/depot_tools/third_party/boto/gs/connection.py +0 -103
- data/vendor/depot_tools/third_party/boto/gs/cors.py +0 -169
- data/vendor/depot_tools/third_party/boto/gs/key.py +0 -704
- data/vendor/depot_tools/third_party/boto/gs/resumable_upload_handler.py +0 -659
- data/vendor/depot_tools/third_party/boto/gs/user.py +0 -54
- data/vendor/depot_tools/third_party/boto/handler.py +0 -44
- data/vendor/depot_tools/third_party/boto/https_connection.py +0 -124
- data/vendor/depot_tools/third_party/boto/jsonresponse.py +0 -163
- data/vendor/depot_tools/third_party/boto/manage/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/manage/cmdshell.py +0 -241
- data/vendor/depot_tools/third_party/boto/manage/propget.py +0 -64
- data/vendor/depot_tools/third_party/boto/manage/server.py +0 -556
- data/vendor/depot_tools/third_party/boto/manage/task.py +0 -175
- data/vendor/depot_tools/third_party/boto/manage/test_manage.py +0 -34
- data/vendor/depot_tools/third_party/boto/manage/volume.py +0 -420
- data/vendor/depot_tools/third_party/boto/mashups/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/mashups/interactive.py +0 -97
- data/vendor/depot_tools/third_party/boto/mashups/iobject.py +0 -115
- data/vendor/depot_tools/third_party/boto/mashups/order.py +0 -211
- data/vendor/depot_tools/third_party/boto/mashups/server.py +0 -395
- data/vendor/depot_tools/third_party/boto/plugin.py +0 -90
- data/vendor/depot_tools/third_party/boto/provider.py +0 -337
- data/vendor/depot_tools/third_party/boto/pyami/__init__.py +0 -22
- data/vendor/depot_tools/third_party/boto/pyami/bootstrap.py +0 -134
- data/vendor/depot_tools/third_party/boto/pyami/config.py +0 -229
- data/vendor/depot_tools/third_party/boto/pyami/copybot.cfg +0 -60
- data/vendor/depot_tools/third_party/boto/pyami/copybot.py +0 -97
- data/vendor/depot_tools/third_party/boto/pyami/helloworld.py +0 -28
- data/vendor/depot_tools/third_party/boto/pyami/launch_ami.py +0 -178
- data/vendor/depot_tools/third_party/boto/pyami/scriptbase.py +0 -44
- data/vendor/depot_tools/third_party/boto/pyami/startup.py +0 -60
- data/vendor/depot_tools/third_party/boto/regioninfo.py +0 -63
- data/vendor/depot_tools/third_party/boto/resultset.py +0 -169
- data/vendor/depot_tools/third_party/boto/roboto/__init__.py +0 -1
- data/vendor/depot_tools/third_party/boto/roboto/awsqueryrequest.py +0 -504
- data/vendor/depot_tools/third_party/boto/roboto/awsqueryservice.py +0 -121
- data/vendor/depot_tools/third_party/boto/roboto/param.py +0 -147
- data/vendor/depot_tools/third_party/boto/s3/__init__.py +0 -84
- data/vendor/depot_tools/third_party/boto/s3/acl.py +0 -164
- data/vendor/depot_tools/third_party/boto/s3/bucket.py +0 -1634
- data/vendor/depot_tools/third_party/boto/s3/bucketlistresultset.py +0 -139
- data/vendor/depot_tools/third_party/boto/s3/bucketlogging.py +0 -83
- data/vendor/depot_tools/third_party/boto/s3/connection.py +0 -540
- data/vendor/depot_tools/third_party/boto/s3/cors.py +0 -210
- data/vendor/depot_tools/third_party/boto/s3/deletemarker.py +0 -55
- data/vendor/depot_tools/third_party/boto/s3/key.py +0 -1712
- data/vendor/depot_tools/third_party/boto/s3/keyfile.py +0 -134
- data/vendor/depot_tools/third_party/boto/s3/lifecycle.py +0 -231
- data/vendor/depot_tools/third_party/boto/s3/multidelete.py +0 -138
- data/vendor/depot_tools/third_party/boto/s3/multipart.py +0 -315
- data/vendor/depot_tools/third_party/boto/s3/prefix.py +0 -42
- data/vendor/depot_tools/third_party/boto/s3/resumable_download_handler.py +0 -339
- data/vendor/depot_tools/third_party/boto/s3/tagging.py +0 -71
- data/vendor/depot_tools/third_party/boto/s3/user.py +0 -49
- data/vendor/depot_tools/third_party/boto/s3/website.py +0 -237
- data/vendor/depot_tools/third_party/boto/services/__init__.py +0 -23
- data/vendor/depot_tools/third_party/boto/services/bs.py +0 -179
- data/vendor/depot_tools/third_party/boto/services/message.py +0 -58
- data/vendor/depot_tools/third_party/boto/services/result.py +0 -136
- data/vendor/depot_tools/third_party/boto/services/service.py +0 -161
- data/vendor/depot_tools/third_party/boto/services/servicedef.py +0 -91
- data/vendor/depot_tools/third_party/boto/services/sonofmmm.cfg +0 -43
- data/vendor/depot_tools/third_party/boto/services/sonofmmm.py +0 -81
- data/vendor/depot_tools/third_party/boto/services/submit.py +0 -88
- data/vendor/depot_tools/third_party/boto/ses/__init__.py +0 -54
- data/vendor/depot_tools/third_party/boto/ses/connection.py +0 -521
- data/vendor/depot_tools/third_party/boto/ses/exceptions.py +0 -77
- data/vendor/depot_tools/third_party/boto/storage_uri.py +0 -835
- data/vendor/depot_tools/third_party/boto/sts/__init__.py +0 -55
- data/vendor/depot_tools/third_party/boto/sts/connection.py +0 -207
- data/vendor/depot_tools/third_party/boto/sts/credentials.py +0 -215
- data/vendor/depot_tools/third_party/boto/utils.py +0 -927
- data/vendor/depot_tools/third_party/colorama/README.txt +0 -304
- data/vendor/depot_tools/third_party/fancy_urllib/README +0 -22
- data/vendor/depot_tools/third_party/fancy_urllib/__init__.py +0 -460
- data/vendor/depot_tools/third_party/logilab/README.chromium +0 -6
- data/vendor/depot_tools/third_party/logilab/__init__.py +0 -0
- data/vendor/depot_tools/third_party/logilab/astroid/LICENSE.txt +0 -340
- data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +0 -136
- data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +0 -42
- data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +0 -233
- data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +0 -548
- data/vendor/depot_tools/third_party/logilab/astroid/astpeephole.py +0 -86
- data/vendor/depot_tools/third_party/logilab/astroid/bases.py +0 -636
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_builtin_inference.py +0 -336
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +0 -15
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_gi.py +0 -195
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_mechanize.py +0 -18
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_nose.py +0 -82
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +0 -62
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +0 -76
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +0 -44
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_six.py +0 -288
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +0 -65
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +0 -473
- data/vendor/depot_tools/third_party/logilab/astroid/builder.py +0 -263
- data/vendor/depot_tools/third_party/logilab/astroid/context.py +0 -81
- data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +0 -75
- data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +0 -71
- data/vendor/depot_tools/third_party/logilab/astroid/inference.py +0 -359
- data/vendor/depot_tools/third_party/logilab/astroid/manager.py +0 -267
- data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +0 -147
- data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +0 -741
- data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +0 -1053
- data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +0 -87
- data/vendor/depot_tools/third_party/logilab/astroid/objects.py +0 -186
- data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +0 -470
- data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +0 -390
- data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +0 -989
- data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +0 -1716
- data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +0 -201
- data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +0 -96
- data/vendor/depot_tools/third_party/logilab/astroid/util.py +0 -89
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +0 -19
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +0 -20
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +0 -1421
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +0 -9
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +0 -246
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +0 -414
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +0 -13
- data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +0 -24
- data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +0 -19
- data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +0 -2729
- data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +0 -96
- data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +0 -512
- data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +0 -228
- data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +0 -901
- data/vendor/depot_tools/third_party/mock/LICENSE.txt +0 -26
- data/vendor/depot_tools/third_party/mock/README.chromium +0 -24
- data/vendor/depot_tools/third_party/mock/__init__.py +0 -2366
- data/vendor/depot_tools/third_party/oauth2client/LICENSE +0 -202
- data/vendor/depot_tools/third_party/oauth2client/MODIFICATIONS.diff +0 -66
- data/vendor/depot_tools/third_party/oauth2client/README.chromium +0 -15
- data/vendor/depot_tools/third_party/oauth2client/__init__.py +0 -5
- data/vendor/depot_tools/third_party/oauth2client/anyjson.py +0 -32
- data/vendor/depot_tools/third_party/oauth2client/appengine.py +0 -963
- data/vendor/depot_tools/third_party/oauth2client/client.py +0 -1363
- data/vendor/depot_tools/third_party/oauth2client/clientsecrets.py +0 -153
- data/vendor/depot_tools/third_party/oauth2client/crypt.py +0 -377
- data/vendor/depot_tools/third_party/oauth2client/django_orm.py +0 -134
- data/vendor/depot_tools/third_party/oauth2client/file.py +0 -124
- data/vendor/depot_tools/third_party/oauth2client/gce.py +0 -90
- data/vendor/depot_tools/third_party/oauth2client/keyring_storage.py +0 -109
- data/vendor/depot_tools/third_party/oauth2client/locked_file.py +0 -373
- data/vendor/depot_tools/third_party/oauth2client/multistore_file.py +0 -465
- data/vendor/depot_tools/third_party/oauth2client/old_run.py +0 -160
- data/vendor/depot_tools/third_party/oauth2client/tools.py +0 -243
- data/vendor/depot_tools/third_party/oauth2client/util.py +0 -196
- data/vendor/depot_tools/third_party/oauth2client/xsrfutil.py +0 -113
- data/vendor/depot_tools/third_party/protobuf26/README.chromium +0 -23
- data/vendor/depot_tools/third_party/protobuf26/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/compiler/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/compiler/plugin_pb2.py +0 -184
- data/vendor/depot_tools/third_party/protobuf26/descriptor.py +0 -849
- data/vendor/depot_tools/third_party/protobuf26/descriptor_database.py +0 -137
- data/vendor/depot_tools/third_party/protobuf26/descriptor_pb2.py +0 -1522
- data/vendor/depot_tools/third_party/protobuf26/descriptor_pool.py +0 -643
- data/vendor/depot_tools/third_party/protobuf26/internal/__init__.py +0 -0
- data/vendor/depot_tools/third_party/protobuf26/internal/api_implementation.py +0 -89
- data/vendor/depot_tools/third_party/protobuf26/internal/containers.py +0 -269
- data/vendor/depot_tools/third_party/protobuf26/internal/cpp_message.py +0 -663
- data/vendor/depot_tools/third_party/protobuf26/internal/decoder.py +0 -831
- data/vendor/depot_tools/third_party/protobuf26/internal/encoder.py +0 -788
- data/vendor/depot_tools/third_party/protobuf26/internal/enum_type_wrapper.py +0 -89
- data/vendor/depot_tools/third_party/protobuf26/internal/message_listener.py +0 -78
- data/vendor/depot_tools/third_party/protobuf26/internal/python_message.py +0 -1247
- data/vendor/depot_tools/third_party/protobuf26/internal/type_checkers.py +0 -328
- data/vendor/depot_tools/third_party/protobuf26/internal/wire_format.py +0 -268
- data/vendor/depot_tools/third_party/protobuf26/message.py +0 -284
- data/vendor/depot_tools/third_party/protobuf26/message_factory.py +0 -155
- data/vendor/depot_tools/third_party/protobuf26/reflection.py +0 -205
- data/vendor/depot_tools/third_party/protobuf26/service.py +0 -226
- data/vendor/depot_tools/third_party/protobuf26/service_reflection.py +0 -284
- data/vendor/depot_tools/third_party/protobuf26/symbol_database.py +0 -185
- data/vendor/depot_tools/third_party/protobuf26/text_encoding.py +0 -110
- data/vendor/depot_tools/third_party/protobuf26/text_format.py +0 -873
- data/vendor/depot_tools/third_party/pylint.py +0 -37
- data/vendor/depot_tools/third_party/pylint/LICENSE.txt +0 -340
- data/vendor/depot_tools/third_party/pylint/README.chromium +0 -30
- data/vendor/depot_tools/third_party/pylint/__init__.py +0 -46
- data/vendor/depot_tools/third_party/pylint/__main__.py +0 -3
- data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +0 -80
- data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +0 -123
- data/vendor/depot_tools/third_party/pylint/checkers/async.py +0 -82
- data/vendor/depot_tools/third_party/pylint/checkers/base.py +0 -2010
- data/vendor/depot_tools/third_party/pylint/checkers/classes.py +0 -1120
- data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +0 -348
- data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +0 -369
- data/vendor/depot_tools/third_party/pylint/checkers/format.py +0 -993
- data/vendor/depot_tools/third_party/pylint/checkers/imports.py +0 -654
- data/vendor/depot_tools/third_party/pylint/checkers/logging.py +0 -258
- data/vendor/depot_tools/third_party/pylint/checkers/misc.py +0 -105
- data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +0 -169
- data/vendor/depot_tools/third_party/pylint/checkers/python3.py +0 -591
- data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +0 -129
- data/vendor/depot_tools/third_party/pylint/checkers/similar.py +0 -371
- data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +0 -264
- data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +0 -280
- data/vendor/depot_tools/third_party/pylint/checkers/strings.py +0 -618
- data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +0 -974
- data/vendor/depot_tools/third_party/pylint/checkers/utils.py +0 -741
- data/vendor/depot_tools/third_party/pylint/checkers/variables.py +0 -1191
- data/vendor/depot_tools/third_party/pylint/config.py +0 -820
- data/vendor/depot_tools/third_party/pylint/epylint.py +0 -181
- data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +0 -311
- data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +0 -62
- data/vendor/depot_tools/third_party/pylint/graph.py +0 -179
- data/vendor/depot_tools/third_party/pylint/gui.py +0 -531
- data/vendor/depot_tools/third_party/pylint/interfaces.py +0 -102
- data/vendor/depot_tools/third_party/pylint/lint.py +0 -1381
- data/vendor/depot_tools/third_party/pylint/pyreverse/__init__.py +0 -5
- data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +0 -230
- data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +0 -258
- data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +0 -372
- data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +0 -147
- data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +0 -210
- data/vendor/depot_tools/third_party/pylint/pyreverse/vcgutils.py +0 -198
- data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +0 -198
- data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +0 -149
- data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +0 -27
- data/vendor/depot_tools/third_party/pylint/reporters/html.py +0 -108
- data/vendor/depot_tools/third_party/pylint/reporters/json.py +0 -64
- data/vendor/depot_tools/third_party/pylint/reporters/text.py +0 -237
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +0 -106
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/html_writer.py +0 -93
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/nodes.py +0 -181
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/text_writer.py +0 -99
- data/vendor/depot_tools/third_party/pylint/testutils.py +0 -414
- data/vendor/depot_tools/third_party/pylint/utils.py +0 -1148
- data/vendor/depot_tools/third_party/pymox/COPYING +0 -202
- data/vendor/depot_tools/third_party/pymox/MANIFEST.in +0 -5
- data/vendor/depot_tools/third_party/pymox/README +0 -56
- data/vendor/depot_tools/third_party/pymox/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pymox/mox.py +0 -1643
- data/vendor/depot_tools/third_party/pymox/mox_test.py +0 -1708
- data/vendor/depot_tools/third_party/pymox/mox_test_helper.py +0 -76
- data/vendor/depot_tools/third_party/pymox/setup.py +0 -14
- data/vendor/depot_tools/third_party/pymox/stubout.py +0 -142
- data/vendor/depot_tools/third_party/pymox/stubout_test.py +0 -47
- data/vendor/depot_tools/third_party/pymox/stubout_testee.py +0 -2
- data/vendor/depot_tools/third_party/simplejson/LICENSE.txt +0 -19
- data/vendor/depot_tools/third_party/simplejson/PKG-INFO +0 -29
- data/vendor/depot_tools/third_party/simplejson/__init__.py +0 -437
- data/vendor/depot_tools/third_party/simplejson/decoder.py +0 -421
- data/vendor/depot_tools/third_party/simplejson/encoder.py +0 -501
- data/vendor/depot_tools/third_party/simplejson/ordered_dict.py +0 -119
- data/vendor/depot_tools/third_party/simplejson/scanner.py +0 -77
- data/vendor/depot_tools/third_party/simplejson/tool.py +0 -39
- data/vendor/depot_tools/third_party/upload.py +0 -2565
@@ -1,1716 +0,0 @@
|
|
1
|
-
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
|
2
|
-
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
|
3
|
-
#
|
4
|
-
# This file is part of astroid.
|
5
|
-
#
|
6
|
-
# astroid is free software: you can redistribute it and/or modify it
|
7
|
-
# under the terms of the GNU Lesser General Public License as published by the
|
8
|
-
# Free Software Foundation, either version 2.1 of the License, or (at your
|
9
|
-
# option) any later version.
|
10
|
-
#
|
11
|
-
# astroid is distributed in the hope that it will be useful, but
|
12
|
-
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
13
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
14
|
-
# for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
17
|
-
# with astroid. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
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
|
-
"""
|
24
|
-
|
25
|
-
import io
|
26
|
-
import itertools
|
27
|
-
import warnings
|
28
|
-
|
29
|
-
import six
|
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
|
-
|
41
|
-
|
42
|
-
BUILTINS = six.moves.builtins.__name__
|
43
|
-
ITER_METHODS = ('__iter__', '__getitem__')
|
44
|
-
|
45
|
-
|
46
|
-
def _c3_merge(sequences):
|
47
|
-
"""Merges MROs in *sequences* to a single MRO using the C3 algorithm.
|
48
|
-
|
49
|
-
Adapted from http://www.python.org/download/releases/2.3/mro/.
|
50
|
-
|
51
|
-
"""
|
52
|
-
result = []
|
53
|
-
while True:
|
54
|
-
sequences = [s for s in sequences if s] # purge empty sequences
|
55
|
-
if not sequences:
|
56
|
-
return result
|
57
|
-
for s1 in sequences: # find merge candidates among seq heads
|
58
|
-
candidate = s1[0]
|
59
|
-
for s2 in sequences:
|
60
|
-
if candidate in s2[1:]:
|
61
|
-
candidate = None
|
62
|
-
break # reject the current head, it appears later
|
63
|
-
else:
|
64
|
-
break
|
65
|
-
if not candidate:
|
66
|
-
# Show all the remaining bases, which were considered as
|
67
|
-
# candidates for the next mro sequence.
|
68
|
-
bases = ["({})".format(", ".join(base.name
|
69
|
-
for base in subsequence))
|
70
|
-
for subsequence in sequences]
|
71
|
-
raise exceptions.InconsistentMroError(
|
72
|
-
"Cannot create a consistent method resolution "
|
73
|
-
"order for bases %s" % ", ".join(bases))
|
74
|
-
|
75
|
-
result.append(candidate)
|
76
|
-
# remove the chosen candidate
|
77
|
-
for seq in sequences:
|
78
|
-
if seq[0] == candidate:
|
79
|
-
del seq[0]
|
80
|
-
|
81
|
-
|
82
|
-
def _verify_duplicates_mro(sequences):
|
83
|
-
for sequence in sequences:
|
84
|
-
names = [node.qname() for node in sequence]
|
85
|
-
if len(names) != len(set(names)):
|
86
|
-
raise exceptions.DuplicateBasesError('Duplicates found in the mro.')
|
87
|
-
|
88
|
-
|
89
|
-
def remove_nodes(cls):
|
90
|
-
@wrapt.decorator
|
91
|
-
def decorator(func, instance, args, kwargs):
|
92
|
-
nodes = [n for n in func(*args, **kwargs) if not isinstance(n, cls)]
|
93
|
-
if not nodes:
|
94
|
-
raise exceptions.NotFoundError()
|
95
|
-
return nodes
|
96
|
-
return decorator
|
97
|
-
|
98
|
-
|
99
|
-
def function_to_method(n, klass):
|
100
|
-
if isinstance(n, FunctionDef):
|
101
|
-
if n.type == 'classmethod':
|
102
|
-
return bases.BoundMethod(n, klass)
|
103
|
-
if n.type != 'staticmethod':
|
104
|
-
return bases.UnboundMethod(n)
|
105
|
-
return n
|
106
|
-
|
107
|
-
|
108
|
-
def std_special_attributes(self, name, add_locals=True):
|
109
|
-
if add_locals:
|
110
|
-
locals = self._locals
|
111
|
-
else:
|
112
|
-
locals = {}
|
113
|
-
if name == '__name__':
|
114
|
-
return [node_classes.const_factory(self.name)] + locals.get(name, [])
|
115
|
-
if name == '__doc__':
|
116
|
-
return [node_classes.const_factory(self.doc)] + locals.get(name, [])
|
117
|
-
if name == '__dict__':
|
118
|
-
return [node_classes.Dict()] + locals.get(name, [])
|
119
|
-
raise exceptions.NotFoundError(name)
|
120
|
-
|
121
|
-
|
122
|
-
MANAGER = manager.AstroidManager()
|
123
|
-
def builtin_lookup(name):
|
124
|
-
"""lookup a name into the builtin module
|
125
|
-
return the list of matching statements and the astroid for the builtin
|
126
|
-
module
|
127
|
-
"""
|
128
|
-
builtin_astroid = MANAGER.ast_from_module(six.moves.builtins)
|
129
|
-
if name == '__dict__':
|
130
|
-
return builtin_astroid, ()
|
131
|
-
try:
|
132
|
-
stmts = builtin_astroid._locals[name]
|
133
|
-
except KeyError:
|
134
|
-
stmts = ()
|
135
|
-
return builtin_astroid, stmts
|
136
|
-
|
137
|
-
|
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
|
142
|
-
to locals information
|
143
|
-
"""
|
144
|
-
|
145
|
-
# attributes below are set by the builder module or by raw factories
|
146
|
-
|
147
|
-
# dictionary of locals with name as key and node defining the local as
|
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
|
161
|
-
|
162
|
-
def qname(self):
|
163
|
-
"""return the 'qualified' name of the node, eg module.name,
|
164
|
-
module.class.name ...
|
165
|
-
"""
|
166
|
-
if self.parent is None:
|
167
|
-
return self.name
|
168
|
-
return '%s.%s' % (self.parent.frame().qname(), self.name)
|
169
|
-
|
170
|
-
def frame(self):
|
171
|
-
"""return the first parent frame node (i.e. Module, FunctionDef or ClassDef)
|
172
|
-
"""
|
173
|
-
return self
|
174
|
-
|
175
|
-
def scope(self):
|
176
|
-
"""return the first node defining a new scope (i.e. Module,
|
177
|
-
FunctionDef, ClassDef, Lambda but also GeneratorExp, DictComp and SetComp)
|
178
|
-
"""
|
179
|
-
return self
|
180
|
-
|
181
|
-
def _scope_lookup(self, node, name, offset=0):
|
182
|
-
"""XXX method for interfacing the scope lookup"""
|
183
|
-
try:
|
184
|
-
stmts = node._filter_stmts(self._locals[name], self, offset)
|
185
|
-
except KeyError:
|
186
|
-
stmts = ()
|
187
|
-
if stmts:
|
188
|
-
return self, stmts
|
189
|
-
if self.parent: # i.e. not Module
|
190
|
-
# nested scope: if parent scope is a function, that's fine
|
191
|
-
# else jump to the module
|
192
|
-
pscope = self.parent.scope()
|
193
|
-
if not pscope.is_function:
|
194
|
-
pscope = pscope.root()
|
195
|
-
return pscope.scope_lookup(node, name)
|
196
|
-
return builtin_lookup(name) # Module
|
197
|
-
|
198
|
-
def set_local(self, name, stmt):
|
199
|
-
"""define <name> in locals (<stmt> is the node defining the name)
|
200
|
-
if the node is a Module node (i.e. has globals), add the name to
|
201
|
-
globals
|
202
|
-
|
203
|
-
if the name is already defined, ignore it
|
204
|
-
"""
|
205
|
-
#assert not stmt in self._locals.get(name, ()), (self, stmt)
|
206
|
-
self._locals.setdefault(name, []).append(stmt)
|
207
|
-
|
208
|
-
__setitem__ = set_local
|
209
|
-
|
210
|
-
def _append_node(self, child):
|
211
|
-
"""append a child, linking it in the tree"""
|
212
|
-
self.body.append(child)
|
213
|
-
child.parent = self
|
214
|
-
|
215
|
-
def add_local_node(self, child_node, name=None):
|
216
|
-
"""append a child which should alter locals to the given node"""
|
217
|
-
if name != '__class__':
|
218
|
-
# add __class__ node as a child will cause infinite recursion later!
|
219
|
-
self._append_node(child_node)
|
220
|
-
self.set_local(name or child_node.name, child_node)
|
221
|
-
|
222
|
-
def __getitem__(self, item):
|
223
|
-
"""method from the `dict` interface returning the first node
|
224
|
-
associated with the given name in the locals dictionary
|
225
|
-
|
226
|
-
:type item: str
|
227
|
-
:param item: the name of the locally defined object
|
228
|
-
:raises KeyError: if the name is not defined
|
229
|
-
"""
|
230
|
-
return self._locals[item][0]
|
231
|
-
|
232
|
-
def __iter__(self):
|
233
|
-
"""method from the `dict` interface returning an iterator on
|
234
|
-
`self.keys()`
|
235
|
-
"""
|
236
|
-
return iter(self.keys())
|
237
|
-
|
238
|
-
def keys(self):
|
239
|
-
"""method from the `dict` interface returning a tuple containing
|
240
|
-
locally defined names
|
241
|
-
"""
|
242
|
-
return list(self._locals.keys())
|
243
|
-
|
244
|
-
def values(self):
|
245
|
-
"""method from the `dict` interface returning a tuple containing
|
246
|
-
locally defined nodes which are instance of `FunctionDef` or `ClassDef`
|
247
|
-
"""
|
248
|
-
return [self[key] for key in self.keys()]
|
249
|
-
|
250
|
-
def items(self):
|
251
|
-
"""method from the `dict` interface returning a list of tuple
|
252
|
-
containing each locally defined name with its associated node,
|
253
|
-
which is an instance of `FunctionDef` or `ClassDef`
|
254
|
-
"""
|
255
|
-
return list(zip(self.keys(), self.values()))
|
256
|
-
|
257
|
-
def __contains__(self, name):
|
258
|
-
return name in self._locals
|
259
|
-
|
260
|
-
|
261
|
-
class Module(LocalsDictNodeNG):
|
262
|
-
_astroid_fields = ('body',)
|
263
|
-
|
264
|
-
fromlineno = 0
|
265
|
-
lineno = 0
|
266
|
-
|
267
|
-
# attributes below are set by the builder module or by raw factories
|
268
|
-
|
269
|
-
# the file from which as been extracted the astroid representation. It may
|
270
|
-
# be None if the representation has been built from a built-in module
|
271
|
-
source_file = None
|
272
|
-
# Alternatively, if built from a string/bytes, this can be set
|
273
|
-
source_code = None
|
274
|
-
# encoding of python source file, so we can get unicode out of it (python2
|
275
|
-
# only)
|
276
|
-
file_encoding = None
|
277
|
-
# the module name
|
278
|
-
name = None
|
279
|
-
# boolean for astroid built from source (i.e. ast)
|
280
|
-
pure_python = None
|
281
|
-
# boolean for package module
|
282
|
-
package = None
|
283
|
-
# dictionary of globals with name as key and node defining the global
|
284
|
-
# as value
|
285
|
-
_globals = None
|
286
|
-
|
287
|
-
# Future imports
|
288
|
-
_future_imports = None
|
289
|
-
|
290
|
-
# names of python special attributes (handled by getattr impl.)
|
291
|
-
special_attributes = set(('__name__', '__doc__', '__file__', '__path__',
|
292
|
-
'__dict__'))
|
293
|
-
# names of module attributes available through the global scope
|
294
|
-
scope_attrs = set(('__name__', '__doc__', '__file__', '__path__'))
|
295
|
-
|
296
|
-
def __init__(self, name, doc, pure_python=True):
|
297
|
-
self.name = name
|
298
|
-
self.doc = doc
|
299
|
-
self.pure_python = pure_python
|
300
|
-
self._locals = self._globals = {}
|
301
|
-
self.body = []
|
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
|
369
|
-
|
370
|
-
def _get_stream(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')
|
375
|
-
return stream
|
376
|
-
return None
|
377
|
-
|
378
|
-
@property
|
379
|
-
def file_stream(self):
|
380
|
-
warnings.warn("file_stream property is deprecated and "
|
381
|
-
"it is slated for removal in astroid 1.6."
|
382
|
-
"Use the new method 'stream' instead.",
|
383
|
-
PendingDeprecationWarning,
|
384
|
-
stacklevel=2)
|
385
|
-
return self._get_stream()
|
386
|
-
|
387
|
-
def stream(self):
|
388
|
-
"""Get a stream to the underlying file or bytes."""
|
389
|
-
return self._get_stream()
|
390
|
-
|
391
|
-
def close(self):
|
392
|
-
"""Close the underlying file streams."""
|
393
|
-
warnings.warn("close method is deprecated and it is "
|
394
|
-
"slated for removal in astroid 1.6, along "
|
395
|
-
"with 'file_stream' property. "
|
396
|
-
"Its behaviour is replaced by managing each "
|
397
|
-
"file stream returned by the 'stream' method.",
|
398
|
-
PendingDeprecationWarning,
|
399
|
-
stacklevel=2)
|
400
|
-
|
401
|
-
def block_range(self, lineno):
|
402
|
-
"""return block line numbers.
|
403
|
-
|
404
|
-
start from the beginning whatever the given lineno
|
405
|
-
"""
|
406
|
-
return self.fromlineno, self.tolineno
|
407
|
-
|
408
|
-
def scope_lookup(self, node, name, offset=0):
|
409
|
-
if name in self.scope_attrs and name not in self._locals:
|
410
|
-
try:
|
411
|
-
return self, self.getattr(name)
|
412
|
-
except exceptions.NotFoundError:
|
413
|
-
return self, ()
|
414
|
-
return self._scope_lookup(node, name, offset)
|
415
|
-
|
416
|
-
def pytype(self):
|
417
|
-
return '%s.module' % BUILTINS
|
418
|
-
|
419
|
-
def display_type(self):
|
420
|
-
return 'Module'
|
421
|
-
|
422
|
-
@remove_nodes(node_classes.DelName)
|
423
|
-
def getattr(self, name, context=None, ignore_locals=False):
|
424
|
-
if name in self.special_attributes:
|
425
|
-
if name == '__file__':
|
426
|
-
return [node_classes.const_factory(self.source_file)] + self._locals.get(name, [])
|
427
|
-
if name == '__path__' and self.package:
|
428
|
-
return [node_classes.List()] + self._locals.get(name, [])
|
429
|
-
return std_special_attributes(self, name)
|
430
|
-
if not ignore_locals and name in self._locals:
|
431
|
-
return self._locals[name]
|
432
|
-
if self.package:
|
433
|
-
try:
|
434
|
-
return [self.import_module(name, relative_only=True)]
|
435
|
-
except exceptions.AstroidBuildingException:
|
436
|
-
raise exceptions.NotFoundError(name)
|
437
|
-
except SyntaxError:
|
438
|
-
raise exceptions.NotFoundError(name)
|
439
|
-
raise exceptions.NotFoundError(name)
|
440
|
-
|
441
|
-
def igetattr(self, name, context=None):
|
442
|
-
"""inferred getattr"""
|
443
|
-
# set lookup name since this is necessary to infer on import nodes for
|
444
|
-
# instance
|
445
|
-
context = contextmod.copy_context(context)
|
446
|
-
context.lookupname = name
|
447
|
-
try:
|
448
|
-
return bases._infer_stmts(self.getattr(name, context),
|
449
|
-
context, frame=self)
|
450
|
-
except exceptions.NotFoundError:
|
451
|
-
raise exceptions.InferenceError(name)
|
452
|
-
|
453
|
-
def fully_defined(self):
|
454
|
-
"""return True if this module has been built from a .py file
|
455
|
-
and so contains a complete representation including the code
|
456
|
-
"""
|
457
|
-
return self.source_file is not None and self.source_file.endswith('.py')
|
458
|
-
|
459
|
-
def statement(self):
|
460
|
-
"""return the first parent node marked as statement node
|
461
|
-
consider a module as a statement...
|
462
|
-
"""
|
463
|
-
return self
|
464
|
-
|
465
|
-
def previous_sibling(self):
|
466
|
-
"""module has no sibling"""
|
467
|
-
return
|
468
|
-
|
469
|
-
def next_sibling(self):
|
470
|
-
"""module has no sibling"""
|
471
|
-
return
|
472
|
-
|
473
|
-
if six.PY2:
|
474
|
-
@decorators_mod.cachedproperty
|
475
|
-
def _absolute_import_activated(self):
|
476
|
-
for stmt in self._locals.get('absolute_import', ()):
|
477
|
-
if isinstance(stmt, node_classes.ImportFrom) and stmt.modname == '__future__':
|
478
|
-
return True
|
479
|
-
return False
|
480
|
-
else:
|
481
|
-
_absolute_import_activated = True
|
482
|
-
|
483
|
-
def absolute_import_activated(self):
|
484
|
-
return self._absolute_import_activated
|
485
|
-
|
486
|
-
def import_module(self, modname, relative_only=False, level=None):
|
487
|
-
"""import the given module considering self as context"""
|
488
|
-
if relative_only and level is None:
|
489
|
-
level = 0
|
490
|
-
absmodname = self.relative_to_absolute_name(modname, level)
|
491
|
-
try:
|
492
|
-
return MANAGER.ast_from_module_name(absmodname)
|
493
|
-
except exceptions.AstroidBuildingException:
|
494
|
-
# we only want to import a sub module or package of this module,
|
495
|
-
# skip here
|
496
|
-
if relative_only:
|
497
|
-
raise
|
498
|
-
return MANAGER.ast_from_module_name(modname)
|
499
|
-
|
500
|
-
def relative_to_absolute_name(self, modname, level):
|
501
|
-
"""return the absolute module name for a relative import.
|
502
|
-
|
503
|
-
The relative import can be implicit or explicit.
|
504
|
-
"""
|
505
|
-
# XXX this returns non sens when called on an absolute import
|
506
|
-
# like 'pylint.checkers.astroid.utils'
|
507
|
-
# XXX doesn't return absolute name if self.name isn't absolute name
|
508
|
-
if self.absolute_import_activated() and level is None:
|
509
|
-
return modname
|
510
|
-
if level:
|
511
|
-
if self.package:
|
512
|
-
level = level - 1
|
513
|
-
package_name = self.name.rsplit('.', level)[0]
|
514
|
-
elif self.package:
|
515
|
-
package_name = self.name
|
516
|
-
else:
|
517
|
-
package_name = self.name.rsplit('.', 1)[0]
|
518
|
-
if package_name:
|
519
|
-
if not modname:
|
520
|
-
return package_name
|
521
|
-
return '%s.%s' % (package_name, modname)
|
522
|
-
return modname
|
523
|
-
|
524
|
-
def wildcard_import_names(self):
|
525
|
-
"""return the list of imported names when this module is 'wildcard
|
526
|
-
imported'
|
527
|
-
|
528
|
-
It doesn't include the '__builtins__' name which is added by the
|
529
|
-
current CPython implementation of wildcard imports.
|
530
|
-
"""
|
531
|
-
# We separate the different steps of lookup in try/excepts
|
532
|
-
# to avoid catching too many Exceptions
|
533
|
-
default = [name for name in self.keys() if not name.startswith('_')]
|
534
|
-
try:
|
535
|
-
all = self['__all__']
|
536
|
-
except KeyError:
|
537
|
-
return default
|
538
|
-
|
539
|
-
try:
|
540
|
-
explicit = next(all.assigned_stmts())
|
541
|
-
except exceptions.InferenceError:
|
542
|
-
return default
|
543
|
-
except AttributeError:
|
544
|
-
# not an assignment node
|
545
|
-
# XXX infer?
|
546
|
-
return default
|
547
|
-
|
548
|
-
# Try our best to detect the exported name.
|
549
|
-
inferred = []
|
550
|
-
try:
|
551
|
-
explicit = next(explicit.infer())
|
552
|
-
except exceptions.InferenceError:
|
553
|
-
return default
|
554
|
-
if not isinstance(explicit, (node_classes.Tuple, node_classes.List)):
|
555
|
-
return default
|
556
|
-
|
557
|
-
str_const = lambda node: (isinstance(node, node_classes.Const) and
|
558
|
-
isinstance(node.value, six.string_types))
|
559
|
-
for node in explicit.elts:
|
560
|
-
if str_const(node):
|
561
|
-
inferred.append(node.value)
|
562
|
-
else:
|
563
|
-
try:
|
564
|
-
inferred_node = next(node.infer())
|
565
|
-
except exceptions.InferenceError:
|
566
|
-
continue
|
567
|
-
if str_const(inferred_node):
|
568
|
-
inferred.append(inferred_node.value)
|
569
|
-
return inferred
|
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
|
577
|
-
|
578
|
-
|
579
|
-
class ComprehensionScope(LocalsDictNodeNG):
|
580
|
-
def frame(self):
|
581
|
-
return self.parent.frame()
|
582
|
-
|
583
|
-
scope_lookup = LocalsDictNodeNG._scope_lookup
|
584
|
-
|
585
|
-
|
586
|
-
class GeneratorExp(ComprehensionScope):
|
587
|
-
_astroid_fields = ('elt', 'generators')
|
588
|
-
|
589
|
-
def __init__(self):
|
590
|
-
self._locals = {}
|
591
|
-
self.elt = None
|
592
|
-
self.generators = []
|
593
|
-
|
594
|
-
|
595
|
-
class DictComp(ComprehensionScope):
|
596
|
-
_astroid_fields = ('key', 'value', 'generators')
|
597
|
-
|
598
|
-
def __init__(self):
|
599
|
-
self._locals = {}
|
600
|
-
self.key = None
|
601
|
-
self.value = None
|
602
|
-
self.generators = []
|
603
|
-
|
604
|
-
|
605
|
-
class SetComp(ComprehensionScope):
|
606
|
-
_astroid_fields = ('elt', 'generators')
|
607
|
-
|
608
|
-
def __init__(self):
|
609
|
-
self._locals = {}
|
610
|
-
self.elt = None
|
611
|
-
self.generators = []
|
612
|
-
|
613
|
-
|
614
|
-
class _ListComp(bases.NodeNG):
|
615
|
-
"""class representing a ListComp node"""
|
616
|
-
_astroid_fields = ('elt', 'generators')
|
617
|
-
elt = None
|
618
|
-
generators = None
|
619
|
-
|
620
|
-
|
621
|
-
if six.PY3:
|
622
|
-
class ListComp(_ListComp, ComprehensionScope):
|
623
|
-
"""class representing a ListComp node"""
|
624
|
-
def __init__(self):
|
625
|
-
self._locals = {}
|
626
|
-
else:
|
627
|
-
class ListComp(_ListComp):
|
628
|
-
"""class representing a ListComp node"""
|
629
|
-
|
630
|
-
|
631
|
-
def _infer_decorator_callchain(node):
|
632
|
-
"""Detect decorator call chaining and see if the end result is a
|
633
|
-
static or a classmethod.
|
634
|
-
"""
|
635
|
-
if not isinstance(node, FunctionDef):
|
636
|
-
return
|
637
|
-
if not node.parent:
|
638
|
-
return
|
639
|
-
try:
|
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'
|
653
|
-
|
654
|
-
|
655
|
-
class Lambda(mixins.FilterStmtsMixin, LocalsDictNodeNG):
|
656
|
-
_astroid_fields = ('args', 'body',)
|
657
|
-
name = '<lambda>'
|
658
|
-
|
659
|
-
# function's type, 'function' | 'method' | 'staticmethod' | 'classmethod'
|
660
|
-
type = 'function'
|
661
|
-
|
662
|
-
def __init__(self):
|
663
|
-
self._locals = {}
|
664
|
-
self.args = []
|
665
|
-
self.body = []
|
666
|
-
|
667
|
-
def pytype(self):
|
668
|
-
if 'method' in self.type:
|
669
|
-
return '%s.instancemethod' % BUILTINS
|
670
|
-
return '%s.function' % BUILTINS
|
671
|
-
|
672
|
-
def display_type(self):
|
673
|
-
if 'method' in self.type:
|
674
|
-
return 'Method'
|
675
|
-
return 'Function'
|
676
|
-
|
677
|
-
def callable(self):
|
678
|
-
return True
|
679
|
-
|
680
|
-
def argnames(self):
|
681
|
-
"""return a list of argument names"""
|
682
|
-
if self.args.args: # maybe None with builtin functions
|
683
|
-
names = _rec_get_names(self.args.args)
|
684
|
-
else:
|
685
|
-
names = []
|
686
|
-
if self.args.vararg:
|
687
|
-
names.append(self.args.vararg)
|
688
|
-
if self.args.kwarg:
|
689
|
-
names.append(self.args.kwarg)
|
690
|
-
return names
|
691
|
-
|
692
|
-
def infer_call_result(self, caller, context=None):
|
693
|
-
"""infer what a function is returning when called"""
|
694
|
-
return self.body.infer(context)
|
695
|
-
|
696
|
-
def scope_lookup(self, node, name, offset=0):
|
697
|
-
if node in self.args.defaults or node in self.args.kw_defaults:
|
698
|
-
frame = self.parent.frame()
|
699
|
-
# line offset to avoid that def func(f=func) resolve the default
|
700
|
-
# value to the defined function
|
701
|
-
offset = -1
|
702
|
-
else:
|
703
|
-
# check this is not used in function decorators
|
704
|
-
frame = self
|
705
|
-
return frame._scope_lookup(node, name, offset)
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
class FunctionDef(bases.Statement, Lambda):
|
710
|
-
if six.PY3:
|
711
|
-
_astroid_fields = ('decorators', 'args', 'returns', 'body')
|
712
|
-
returns = None
|
713
|
-
else:
|
714
|
-
_astroid_fields = ('decorators', 'args', 'body')
|
715
|
-
|
716
|
-
special_attributes = set(('__name__', '__doc__', '__dict__'))
|
717
|
-
is_function = True
|
718
|
-
# attributes below are set by the builder module or by raw factories
|
719
|
-
decorators = None
|
720
|
-
|
721
|
-
def __init__(self, name, doc):
|
722
|
-
self._locals = {}
|
723
|
-
self.args = []
|
724
|
-
self.body = []
|
725
|
-
self.name = name
|
726
|
-
self.doc = doc
|
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
|
790
|
-
|
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
|
839
|
-
def fromlineno(self):
|
840
|
-
# lineno is the line number of the first decorator, we want the def
|
841
|
-
# statement lineno
|
842
|
-
lineno = self.lineno
|
843
|
-
if self.decorators is not None:
|
844
|
-
lineno += sum(node.tolineno - node.lineno + 1
|
845
|
-
for node in self.decorators.nodes)
|
846
|
-
|
847
|
-
return lineno
|
848
|
-
|
849
|
-
@decorators_mod.cachedproperty
|
850
|
-
def blockstart_tolineno(self):
|
851
|
-
return self.args.tolineno
|
852
|
-
|
853
|
-
def block_range(self, lineno):
|
854
|
-
"""return block line numbers.
|
855
|
-
|
856
|
-
start from the "def" position whatever the given lineno
|
857
|
-
"""
|
858
|
-
return self.fromlineno, self.tolineno
|
859
|
-
|
860
|
-
def getattr(self, name, context=None):
|
861
|
-
"""this method doesn't look in the instance_attrs dictionary since it's
|
862
|
-
done by an Instance proxy at inference time.
|
863
|
-
"""
|
864
|
-
if name == '__module__':
|
865
|
-
return [node_classes.const_factory(self.root().qname())]
|
866
|
-
if name in self._instance_attrs:
|
867
|
-
return self._instance_attrs[name]
|
868
|
-
return std_special_attributes(self, name, False)
|
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
|
-
|
878
|
-
def is_method(self):
|
879
|
-
"""return true if the function node should be considered as a method"""
|
880
|
-
# check we are defined in a ClassDef, because this is usually expected
|
881
|
-
# (e.g. pylint...) when is_method() return True
|
882
|
-
return self.type != 'function' and isinstance(self.parent.frame(), ClassDef)
|
883
|
-
|
884
|
-
@decorators_mod.cached
|
885
|
-
def decoratornames(self):
|
886
|
-
"""return a list of decorator qualified names"""
|
887
|
-
result = set()
|
888
|
-
decoratornodes = []
|
889
|
-
if self.decorators is not None:
|
890
|
-
# pylint: disable=unsupported-binary-operation; damn flow control.
|
891
|
-
decoratornodes += self.decorators.nodes
|
892
|
-
decoratornodes += self.extra_decorators
|
893
|
-
for decnode in decoratornodes:
|
894
|
-
try:
|
895
|
-
for infnode in decnode.infer():
|
896
|
-
result.add(infnode.qname())
|
897
|
-
except exceptions.InferenceError:
|
898
|
-
continue
|
899
|
-
return result
|
900
|
-
|
901
|
-
def is_bound(self):
|
902
|
-
"""return true if the function is bound to an Instance or a class"""
|
903
|
-
return self.type == 'classmethod'
|
904
|
-
|
905
|
-
def is_abstract(self, pass_is_abstract=True):
|
906
|
-
"""Returns True if the method is abstract.
|
907
|
-
|
908
|
-
A method is considered abstract if
|
909
|
-
- the only statement is 'raise NotImplementedError', or
|
910
|
-
- the only statement is 'pass' and pass_is_abstract is True, or
|
911
|
-
- the method is annotated with abc.astractproperty/abc.abstractmethod
|
912
|
-
"""
|
913
|
-
if self.decorators:
|
914
|
-
for node in self.decorators.nodes:
|
915
|
-
try:
|
916
|
-
inferred = next(node.infer())
|
917
|
-
except exceptions.InferenceError:
|
918
|
-
continue
|
919
|
-
if inferred and inferred.qname() in ('abc.abstractproperty',
|
920
|
-
'abc.abstractmethod'):
|
921
|
-
return True
|
922
|
-
|
923
|
-
for child_node in self.body:
|
924
|
-
if isinstance(child_node, node_classes.Raise):
|
925
|
-
if child_node.raises_not_implemented():
|
926
|
-
return True
|
927
|
-
return pass_is_abstract and isinstance(child_node, node_classes.Pass)
|
928
|
-
# empty function is the same as function with a single "pass" statement
|
929
|
-
if pass_is_abstract:
|
930
|
-
return True
|
931
|
-
|
932
|
-
def is_generator(self):
|
933
|
-
"""return true if this is a generator function"""
|
934
|
-
yield_nodes = (node_classes.Yield, node_classes.YieldFrom)
|
935
|
-
return next(self.nodes_of_class(yield_nodes,
|
936
|
-
skip_klass=(FunctionDef, Lambda)), False)
|
937
|
-
|
938
|
-
def infer_call_result(self, caller, context=None):
|
939
|
-
"""infer what a function is returning when called"""
|
940
|
-
if self.is_generator():
|
941
|
-
result = bases.Generator()
|
942
|
-
result.parent = self
|
943
|
-
yield result
|
944
|
-
return
|
945
|
-
# This is really a gigantic hack to work around metaclass generators
|
946
|
-
# that return transient class-generating functions. Pylint's AST structure
|
947
|
-
# cannot handle a base class object that is only used for calling __new__,
|
948
|
-
# but does not contribute to the inheritance structure itself. We inject
|
949
|
-
# a fake class into the hierarchy here for several well-known metaclass
|
950
|
-
# generators, and filter it out later.
|
951
|
-
if (self.name == 'with_metaclass' and
|
952
|
-
len(self.args.args) == 1 and
|
953
|
-
self.args.vararg is not None):
|
954
|
-
metaclass = next(caller.args[0].infer(context))
|
955
|
-
if isinstance(metaclass, ClassDef):
|
956
|
-
c = ClassDef('temporary_class', None)
|
957
|
-
c.hide = True
|
958
|
-
c.parent = self
|
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]
|
961
|
-
c._metaclass = metaclass
|
962
|
-
yield c
|
963
|
-
return
|
964
|
-
returns = self.nodes_of_class(node_classes.Return, skip_klass=FunctionDef)
|
965
|
-
for returnnode in returns:
|
966
|
-
if returnnode.value is None:
|
967
|
-
yield node_classes.Const(None)
|
968
|
-
else:
|
969
|
-
try:
|
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."""
|
978
|
-
|
979
|
-
|
980
|
-
def _rec_get_names(args, names=None):
|
981
|
-
"""return a list of all argument names"""
|
982
|
-
if names is None:
|
983
|
-
names = []
|
984
|
-
for arg in args:
|
985
|
-
if isinstance(arg, node_classes.Tuple):
|
986
|
-
_rec_get_names(arg.elts, names)
|
987
|
-
else:
|
988
|
-
names.append(arg.name)
|
989
|
-
return names
|
990
|
-
|
991
|
-
|
992
|
-
def _is_metaclass(klass, seen=None):
|
993
|
-
""" Return if the given class can be
|
994
|
-
used as a metaclass.
|
995
|
-
"""
|
996
|
-
if klass.name == 'type':
|
997
|
-
return True
|
998
|
-
if seen is None:
|
999
|
-
seen = set()
|
1000
|
-
for base in klass.bases:
|
1001
|
-
try:
|
1002
|
-
for baseobj in base.infer():
|
1003
|
-
baseobj_name = baseobj.qname()
|
1004
|
-
if baseobj_name in seen:
|
1005
|
-
continue
|
1006
|
-
else:
|
1007
|
-
seen.add(baseobj_name)
|
1008
|
-
if isinstance(baseobj, bases.Instance):
|
1009
|
-
# not abstract
|
1010
|
-
return False
|
1011
|
-
if baseobj is util.YES:
|
1012
|
-
continue
|
1013
|
-
if baseobj is klass:
|
1014
|
-
continue
|
1015
|
-
if not isinstance(baseobj, ClassDef):
|
1016
|
-
continue
|
1017
|
-
if baseobj._type == 'metaclass':
|
1018
|
-
return True
|
1019
|
-
if _is_metaclass(baseobj, seen):
|
1020
|
-
return True
|
1021
|
-
except exceptions.InferenceError:
|
1022
|
-
continue
|
1023
|
-
return False
|
1024
|
-
|
1025
|
-
|
1026
|
-
def _class_type(klass, ancestors=None):
|
1027
|
-
"""return a ClassDef node type to differ metaclass and exception
|
1028
|
-
from 'regular' classes
|
1029
|
-
"""
|
1030
|
-
# XXX we have to store ancestors in case we have a ancestor loop
|
1031
|
-
if klass._type is not None:
|
1032
|
-
return klass._type
|
1033
|
-
if _is_metaclass(klass):
|
1034
|
-
klass._type = 'metaclass'
|
1035
|
-
elif klass.name.endswith('Exception'):
|
1036
|
-
klass._type = 'exception'
|
1037
|
-
else:
|
1038
|
-
if ancestors is None:
|
1039
|
-
ancestors = set()
|
1040
|
-
klass_name = klass.qname()
|
1041
|
-
if klass_name in ancestors:
|
1042
|
-
# XXX we are in loop ancestors, and have found no type
|
1043
|
-
klass._type = 'class'
|
1044
|
-
return 'class'
|
1045
|
-
ancestors.add(klass_name)
|
1046
|
-
for base in klass.ancestors(recurs=False):
|
1047
|
-
name = _class_type(base, ancestors)
|
1048
|
-
if name != 'class':
|
1049
|
-
if name == 'metaclass' and not _is_metaclass(klass):
|
1050
|
-
# don't propagate it if the current class
|
1051
|
-
# can't be a metaclass
|
1052
|
-
continue
|
1053
|
-
klass._type = base.type
|
1054
|
-
break
|
1055
|
-
if klass._type is None:
|
1056
|
-
klass._type = 'class'
|
1057
|
-
return klass._type
|
1058
|
-
|
1059
|
-
|
1060
|
-
class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, bases.Statement):
|
1061
|
-
|
1062
|
-
# some of the attributes below are set by the builder module or
|
1063
|
-
# by a raw factories
|
1064
|
-
|
1065
|
-
# a dictionary of class instances attributes
|
1066
|
-
_astroid_fields = ('decorators', 'bases', 'body') # name
|
1067
|
-
|
1068
|
-
decorators = None
|
1069
|
-
special_attributes = set(('__name__', '__doc__', '__dict__', '__module__',
|
1070
|
-
'__bases__', '__mro__', '__subclasses__'))
|
1071
|
-
|
1072
|
-
_type = None
|
1073
|
-
_metaclass_hack = False
|
1074
|
-
hide = False
|
1075
|
-
type = property(_class_type,
|
1076
|
-
doc="class'type, possible values are 'class' | "
|
1077
|
-
"'metaclass' | 'exception'")
|
1078
|
-
|
1079
|
-
def __init__(self, name, doc):
|
1080
|
-
self._instance_attrs = {}
|
1081
|
-
self._locals = {}
|
1082
|
-
self.bases = []
|
1083
|
-
self.body = []
|
1084
|
-
self.name = name
|
1085
|
-
self.doc = doc
|
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
|
-
|
1100
|
-
def _newstyle_impl(self, context=None):
|
1101
|
-
if context is None:
|
1102
|
-
context = contextmod.InferenceContext()
|
1103
|
-
if self._newstyle is not None:
|
1104
|
-
return self._newstyle
|
1105
|
-
for base in self.ancestors(recurs=False, context=context):
|
1106
|
-
if base._newstyle_impl(context):
|
1107
|
-
self._newstyle = True
|
1108
|
-
break
|
1109
|
-
klass = self._explicit_metaclass()
|
1110
|
-
# could be any callable, we'd need to infer the result of klass(name,
|
1111
|
-
# bases, dict). punt if it's not a class node.
|
1112
|
-
if klass is not None and isinstance(klass, ClassDef):
|
1113
|
-
self._newstyle = klass._newstyle_impl(context)
|
1114
|
-
if self._newstyle is None:
|
1115
|
-
self._newstyle = False
|
1116
|
-
return self._newstyle
|
1117
|
-
|
1118
|
-
_newstyle = None
|
1119
|
-
newstyle = property(_newstyle_impl,
|
1120
|
-
doc="boolean indicating if it's a new style class"
|
1121
|
-
"or not")
|
1122
|
-
|
1123
|
-
@decorators_mod.cachedproperty
|
1124
|
-
def blockstart_tolineno(self):
|
1125
|
-
if self.bases:
|
1126
|
-
return self.bases[-1].tolineno
|
1127
|
-
else:
|
1128
|
-
return self.fromlineno
|
1129
|
-
|
1130
|
-
def block_range(self, lineno):
|
1131
|
-
"""return block line numbers.
|
1132
|
-
|
1133
|
-
start from the "class" position whatever the given lineno
|
1134
|
-
"""
|
1135
|
-
return self.fromlineno, self.tolineno
|
1136
|
-
|
1137
|
-
def pytype(self):
|
1138
|
-
if self.newstyle:
|
1139
|
-
return '%s.type' % BUILTINS
|
1140
|
-
return '%s.classobj' % BUILTINS
|
1141
|
-
|
1142
|
-
def display_type(self):
|
1143
|
-
return 'Class'
|
1144
|
-
|
1145
|
-
def callable(self):
|
1146
|
-
return True
|
1147
|
-
|
1148
|
-
def is_subtype_of(self, type_name, context=None):
|
1149
|
-
if self.qname() == type_name:
|
1150
|
-
return True
|
1151
|
-
for anc in self.ancestors(context=context):
|
1152
|
-
if anc.qname() == type_name:
|
1153
|
-
return True
|
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
|
-
|
1190
|
-
def infer_call_result(self, caller, context=None):
|
1191
|
-
"""infer what a class is returning when called"""
|
1192
|
-
if (self.is_subtype_of('%s.type' % (BUILTINS,), context)
|
1193
|
-
and len(caller.args) == 3):
|
1194
|
-
result = self._infer_type_call(caller, context)
|
1195
|
-
yield result
|
1196
|
-
else:
|
1197
|
-
yield bases.Instance(self)
|
1198
|
-
|
1199
|
-
def scope_lookup(self, node, name, offset=0):
|
1200
|
-
# pylint: disable=redefined-variable-type
|
1201
|
-
if any(node == base or base.parent_of(node)
|
1202
|
-
for base in self.bases):
|
1203
|
-
# Handle the case where we have either a name
|
1204
|
-
# in the bases of a class, which exists before
|
1205
|
-
# the actual definition or the case where we have
|
1206
|
-
# a Getattr node, with that name.
|
1207
|
-
#
|
1208
|
-
# name = ...
|
1209
|
-
# class A(name):
|
1210
|
-
# def name(self): ...
|
1211
|
-
#
|
1212
|
-
# import name
|
1213
|
-
# class A(name.Name):
|
1214
|
-
# def name(self): ...
|
1215
|
-
|
1216
|
-
frame = self.parent.frame()
|
1217
|
-
# line offset to avoid that class A(A) resolve the ancestor to
|
1218
|
-
# the defined class
|
1219
|
-
offset = -1
|
1220
|
-
else:
|
1221
|
-
frame = self
|
1222
|
-
return frame._scope_lookup(node, name, offset)
|
1223
|
-
|
1224
|
-
@property
|
1225
|
-
def basenames(self):
|
1226
|
-
"""Get the list of parent class names, as they appear in the class definition."""
|
1227
|
-
return [bnode.as_string() for bnode in self.bases]
|
1228
|
-
|
1229
|
-
def ancestors(self, recurs=True, context=None):
|
1230
|
-
"""return an iterator on the node base classes in a prefixed
|
1231
|
-
depth first order
|
1232
|
-
|
1233
|
-
:param recurs:
|
1234
|
-
boolean indicating if it should recurse or return direct
|
1235
|
-
ancestors only
|
1236
|
-
"""
|
1237
|
-
# FIXME: should be possible to choose the resolution order
|
1238
|
-
# FIXME: inference make infinite loops possible here
|
1239
|
-
yielded = set([self])
|
1240
|
-
if context is None:
|
1241
|
-
context = contextmod.InferenceContext()
|
1242
|
-
if six.PY3:
|
1243
|
-
if not self.bases and self.qname() != 'builtins.object':
|
1244
|
-
yield builtin_lookup("object")[1][0]
|
1245
|
-
return
|
1246
|
-
|
1247
|
-
for stmt in self.bases:
|
1248
|
-
with context.restore_path():
|
1249
|
-
try:
|
1250
|
-
for baseobj in stmt.infer(context):
|
1251
|
-
if not isinstance(baseobj, ClassDef):
|
1252
|
-
if isinstance(baseobj, bases.Instance):
|
1253
|
-
baseobj = baseobj._proxied
|
1254
|
-
else:
|
1255
|
-
continue
|
1256
|
-
if not baseobj.hide:
|
1257
|
-
if baseobj in yielded:
|
1258
|
-
continue
|
1259
|
-
yielded.add(baseobj)
|
1260
|
-
yield baseobj
|
1261
|
-
if recurs:
|
1262
|
-
for grandpa in baseobj.ancestors(recurs=True,
|
1263
|
-
context=context):
|
1264
|
-
if grandpa is self:
|
1265
|
-
# This class is the ancestor of itself.
|
1266
|
-
break
|
1267
|
-
if grandpa in yielded:
|
1268
|
-
continue
|
1269
|
-
yielded.add(grandpa)
|
1270
|
-
yield grandpa
|
1271
|
-
except exceptions.InferenceError:
|
1272
|
-
continue
|
1273
|
-
|
1274
|
-
def local_attr_ancestors(self, name, context=None):
|
1275
|
-
"""return an iterator on astroid representation of parent classes
|
1276
|
-
which have <name> defined in their locals
|
1277
|
-
"""
|
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:
|
1290
|
-
if name in astroid:
|
1291
|
-
yield astroid
|
1292
|
-
|
1293
|
-
def instance_attr_ancestors(self, name, context=None):
|
1294
|
-
"""return an iterator on astroid representation of parent classes
|
1295
|
-
which have <name> defined in their instance attribute dictionary
|
1296
|
-
"""
|
1297
|
-
for astroid in self.ancestors(context=context):
|
1298
|
-
if name in astroid._instance_attrs:
|
1299
|
-
yield astroid
|
1300
|
-
|
1301
|
-
def has_base(self, node):
|
1302
|
-
return node in self.bases
|
1303
|
-
|
1304
|
-
@remove_nodes(node_classes.DelAttr)
|
1305
|
-
def local_attr(self, name, context=None):
|
1306
|
-
"""return the list of assign node associated to name in this class
|
1307
|
-
locals or in its parents
|
1308
|
-
|
1309
|
-
:raises `NotFoundError`:
|
1310
|
-
if no attribute with this name has been find in this class or
|
1311
|
-
its parent classes
|
1312
|
-
"""
|
1313
|
-
try:
|
1314
|
-
return self._locals[name]
|
1315
|
-
except KeyError:
|
1316
|
-
for class_node in self.local_attr_ancestors(name, context):
|
1317
|
-
return class_node._locals[name]
|
1318
|
-
raise exceptions.NotFoundError(name)
|
1319
|
-
|
1320
|
-
@remove_nodes(node_classes.DelAttr)
|
1321
|
-
def instance_attr(self, name, context=None):
|
1322
|
-
"""return the astroid nodes associated to name in this class instance
|
1323
|
-
attributes dictionary and in its parents
|
1324
|
-
|
1325
|
-
:raises `NotFoundError`:
|
1326
|
-
if no attribute with this name has been find in this class or
|
1327
|
-
its parent classes
|
1328
|
-
"""
|
1329
|
-
# Return a copy, so we don't modify self._instance_attrs,
|
1330
|
-
# which could lead to infinite loop.
|
1331
|
-
values = list(self._instance_attrs.get(name, []))
|
1332
|
-
# get all values from parents
|
1333
|
-
for class_node in self.instance_attr_ancestors(name, context):
|
1334
|
-
values += class_node._instance_attrs[name]
|
1335
|
-
if not values:
|
1336
|
-
raise exceptions.NotFoundError(name)
|
1337
|
-
return values
|
1338
|
-
|
1339
|
-
def instantiate_class(self):
|
1340
|
-
"""return Instance of ClassDef node, else return self"""
|
1341
|
-
return bases.Instance(self)
|
1342
|
-
|
1343
|
-
def instanciate_class(self):
|
1344
|
-
"""return Instance of ClassDef node, else return self"""
|
1345
|
-
util.rename_warning('instanciate_class()', 2.0, 'instantiate_class()')
|
1346
|
-
return self.instantiate_class()
|
1347
|
-
|
1348
|
-
def getattr(self, name, context=None):
|
1349
|
-
"""this method doesn't look in the instance_attrs dictionary since it's
|
1350
|
-
done by an Instance proxy at inference time.
|
1351
|
-
|
1352
|
-
It may return a YES object if the attribute has not been actually
|
1353
|
-
found but a __getattr__ or __getattribute__ method is defined
|
1354
|
-
"""
|
1355
|
-
values = self._locals.get(name, [])
|
1356
|
-
if name in self.special_attributes:
|
1357
|
-
if name == '__module__':
|
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
|
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]
|
1369
|
-
return std_special_attributes(self, name)
|
1370
|
-
# don't modify the list in self._locals!
|
1371
|
-
values = list(values)
|
1372
|
-
for classnode in self.ancestors(recurs=True, context=context):
|
1373
|
-
values += classnode._locals.get(name, [])
|
1374
|
-
if not values:
|
1375
|
-
raise exceptions.NotFoundError(name)
|
1376
|
-
return values
|
1377
|
-
|
1378
|
-
def igetattr(self, name, context=None):
|
1379
|
-
"""inferred getattr, need special treatment in class to handle
|
1380
|
-
descriptors
|
1381
|
-
"""
|
1382
|
-
# set lookup name since this is necessary to infer on import nodes for
|
1383
|
-
# instance
|
1384
|
-
context = contextmod.copy_context(context)
|
1385
|
-
context.lookupname = name
|
1386
|
-
try:
|
1387
|
-
for inferred in bases._infer_stmts(self.getattr(name, context),
|
1388
|
-
context, frame=self):
|
1389
|
-
# yield YES object instead of descriptors when necessary
|
1390
|
-
if (not isinstance(inferred, node_classes.Const)
|
1391
|
-
and isinstance(inferred, bases.Instance)):
|
1392
|
-
try:
|
1393
|
-
inferred._proxied.getattr('__get__', context)
|
1394
|
-
except exceptions.NotFoundError:
|
1395
|
-
yield inferred
|
1396
|
-
else:
|
1397
|
-
yield util.YES
|
1398
|
-
else:
|
1399
|
-
yield function_to_method(inferred, self)
|
1400
|
-
except exceptions.NotFoundError:
|
1401
|
-
if not name.startswith('__') and self.has_dynamic_getattr(context):
|
1402
|
-
# class handle some dynamic attributes, return a YES object
|
1403
|
-
yield util.YES
|
1404
|
-
else:
|
1405
|
-
raise exceptions.InferenceError(name)
|
1406
|
-
|
1407
|
-
def has_dynamic_getattr(self, context=None):
|
1408
|
-
"""
|
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
|
-
|
1420
|
-
try:
|
1421
|
-
return _valid_getattr(self.getattr('__getattr__', context)[0])
|
1422
|
-
except exceptions.NotFoundError:
|
1423
|
-
#if self.newstyle: XXX cause an infinite recursion error
|
1424
|
-
try:
|
1425
|
-
getattribute = self.getattr('__getattribute__', context)[0]
|
1426
|
-
return _valid_getattr(getattribute)
|
1427
|
-
except exceptions.NotFoundError:
|
1428
|
-
pass
|
1429
|
-
return False
|
1430
|
-
|
1431
|
-
def methods(self):
|
1432
|
-
"""return an iterator on all methods defined in the class and
|
1433
|
-
its ancestors
|
1434
|
-
"""
|
1435
|
-
done = {}
|
1436
|
-
for astroid in itertools.chain(iter((self,)), self.ancestors()):
|
1437
|
-
for meth in astroid.mymethods():
|
1438
|
-
if meth.name in done:
|
1439
|
-
continue
|
1440
|
-
done[meth.name] = None
|
1441
|
-
yield meth
|
1442
|
-
|
1443
|
-
def mymethods(self):
|
1444
|
-
"""return an iterator on all methods defined in the class"""
|
1445
|
-
for member in self.values():
|
1446
|
-
if isinstance(member, FunctionDef):
|
1447
|
-
yield member
|
1448
|
-
|
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.
|
1455
|
-
"""
|
1456
|
-
|
1457
|
-
if self.newstyle:
|
1458
|
-
return builtin_lookup('type')[1][0]
|
1459
|
-
|
1460
|
-
_metaclass = None
|
1461
|
-
def _explicit_metaclass(self):
|
1462
|
-
""" Return the explicit defined metaclass
|
1463
|
-
for the current class.
|
1464
|
-
|
1465
|
-
An explicit defined metaclass is defined
|
1466
|
-
either by passing the ``metaclass`` keyword argument
|
1467
|
-
in the class definition line (Python 3) or (Python 2) by
|
1468
|
-
having a ``__metaclass__`` class attribute, or if there are
|
1469
|
-
no explicit bases but there is a global ``__metaclass__`` variable.
|
1470
|
-
"""
|
1471
|
-
for base in self.bases:
|
1472
|
-
try:
|
1473
|
-
for baseobj in base.infer():
|
1474
|
-
if isinstance(baseobj, ClassDef) and baseobj.hide:
|
1475
|
-
self._metaclass = baseobj._metaclass
|
1476
|
-
self._metaclass_hack = True
|
1477
|
-
break
|
1478
|
-
except exceptions.InferenceError:
|
1479
|
-
pass
|
1480
|
-
|
1481
|
-
if self._metaclass:
|
1482
|
-
# Expects this from Py3k TreeRebuilder
|
1483
|
-
try:
|
1484
|
-
return next(node for node in self._metaclass.infer()
|
1485
|
-
if node is not util.YES)
|
1486
|
-
except (exceptions.InferenceError, StopIteration):
|
1487
|
-
return None
|
1488
|
-
if six.PY3:
|
1489
|
-
return None
|
1490
|
-
|
1491
|
-
if '__metaclass__' in self._locals:
|
1492
|
-
assignment = self._locals['__metaclass__'][-1]
|
1493
|
-
elif self.bases:
|
1494
|
-
return None
|
1495
|
-
elif '__metaclass__' in self.root()._locals:
|
1496
|
-
assignments = [ass for ass in self.root()._locals['__metaclass__']
|
1497
|
-
if ass.lineno < self.lineno]
|
1498
|
-
if not assignments:
|
1499
|
-
return None
|
1500
|
-
assignment = assignments[-1]
|
1501
|
-
else:
|
1502
|
-
return None
|
1503
|
-
|
1504
|
-
try:
|
1505
|
-
inferred = next(assignment.infer())
|
1506
|
-
except exceptions.InferenceError:
|
1507
|
-
return
|
1508
|
-
if inferred is util.YES: # don't expose this
|
1509
|
-
return None
|
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
|
1525
|
-
|
1526
|
-
def metaclass(self):
|
1527
|
-
"""Return the metaclass of this class.
|
1528
|
-
|
1529
|
-
If this class does not define explicitly a metaclass,
|
1530
|
-
then the first defined metaclass in ancestors will be used
|
1531
|
-
instead.
|
1532
|
-
"""
|
1533
|
-
return self._find_metaclass()
|
1534
|
-
|
1535
|
-
def has_metaclass_hack(self):
|
1536
|
-
return self._metaclass_hack
|
1537
|
-
|
1538
|
-
def _islots(self):
|
1539
|
-
""" Return an iterator with the inferred slots. """
|
1540
|
-
if '__slots__' not in self._locals:
|
1541
|
-
return
|
1542
|
-
for slots in self.igetattr('__slots__'):
|
1543
|
-
# check if __slots__ is a valid type
|
1544
|
-
for meth in ITER_METHODS:
|
1545
|
-
try:
|
1546
|
-
slots.getattr(meth)
|
1547
|
-
break
|
1548
|
-
except exceptions.NotFoundError:
|
1549
|
-
continue
|
1550
|
-
else:
|
1551
|
-
continue
|
1552
|
-
|
1553
|
-
if isinstance(slots, node_classes.Const):
|
1554
|
-
# a string. Ignore the following checks,
|
1555
|
-
# but yield the node, only if it has a value
|
1556
|
-
if slots.value:
|
1557
|
-
yield slots
|
1558
|
-
continue
|
1559
|
-
if not hasattr(slots, 'itered'):
|
1560
|
-
# we can't obtain the values, maybe a .deque?
|
1561
|
-
continue
|
1562
|
-
|
1563
|
-
if isinstance(slots, node_classes.Dict):
|
1564
|
-
values = [item[0] for item in slots.items]
|
1565
|
-
else:
|
1566
|
-
values = slots.itered()
|
1567
|
-
if values is util.YES:
|
1568
|
-
continue
|
1569
|
-
if not values:
|
1570
|
-
# Stop the iteration, because the class
|
1571
|
-
# has an empty list of slots.
|
1572
|
-
raise StopIteration(values)
|
1573
|
-
|
1574
|
-
for elt in values:
|
1575
|
-
try:
|
1576
|
-
for inferred in elt.infer():
|
1577
|
-
if inferred is util.YES:
|
1578
|
-
continue
|
1579
|
-
if (not isinstance(inferred, node_classes.Const) or
|
1580
|
-
not isinstance(inferred.value,
|
1581
|
-
six.string_types)):
|
1582
|
-
continue
|
1583
|
-
if not inferred.value:
|
1584
|
-
continue
|
1585
|
-
yield inferred
|
1586
|
-
except exceptions.InferenceError:
|
1587
|
-
continue
|
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
|
-
|
1605
|
-
# Cached, because inferring them all the time is expensive
|
1606
|
-
@decorators_mod.cached
|
1607
|
-
def slots(self):
|
1608
|
-
"""Get all the slots for this node.
|
1609
|
-
|
1610
|
-
If the class doesn't define any slot, through `__slots__`
|
1611
|
-
variable, then this function will return a None.
|
1612
|
-
Also, it will return None in the case the slots weren't inferred.
|
1613
|
-
Otherwise, it will return a list of slot names.
|
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
|
-
|
1628
|
-
if not self.newstyle:
|
1629
|
-
raise NotImplementedError(
|
1630
|
-
"The concept of slots is undefined for old-style classes.")
|
1631
|
-
|
1632
|
-
slots = list(grouped_slots())
|
1633
|
-
if not all(slot is not None for slot in slots):
|
1634
|
-
return None
|
1635
|
-
|
1636
|
-
return sorted(slots, key=lambda item: item.value)
|
1637
|
-
|
1638
|
-
def _inferred_bases(self, context=None):
|
1639
|
-
# TODO(cpopa): really similar with .ancestors,
|
1640
|
-
# but the difference is when one base is inferred,
|
1641
|
-
# only the first object is wanted. That's because
|
1642
|
-
# we aren't interested in superclasses, as in the following
|
1643
|
-
# example:
|
1644
|
-
#
|
1645
|
-
# class SomeSuperClass(object): pass
|
1646
|
-
# class SomeClass(SomeSuperClass): pass
|
1647
|
-
# class Test(SomeClass): pass
|
1648
|
-
#
|
1649
|
-
# Inferring SomeClass from the Test's bases will give
|
1650
|
-
# us both SomeClass and SomeSuperClass, but we are interested
|
1651
|
-
# only in SomeClass.
|
1652
|
-
|
1653
|
-
if context is None:
|
1654
|
-
context = contextmod.InferenceContext()
|
1655
|
-
if six.PY3:
|
1656
|
-
if not self.bases and self.qname() != 'builtins.object':
|
1657
|
-
yield builtin_lookup("object")[1][0]
|
1658
|
-
return
|
1659
|
-
|
1660
|
-
for stmt in self.bases:
|
1661
|
-
try:
|
1662
|
-
baseobj = next(stmt.infer(context=context))
|
1663
|
-
except exceptions.InferenceError:
|
1664
|
-
continue
|
1665
|
-
if isinstance(baseobj, bases.Instance):
|
1666
|
-
baseobj = baseobj._proxied
|
1667
|
-
if not isinstance(baseobj, ClassDef):
|
1668
|
-
continue
|
1669
|
-
if not baseobj.hide:
|
1670
|
-
yield baseobj
|
1671
|
-
else:
|
1672
|
-
for base in baseobj.bases:
|
1673
|
-
yield base
|
1674
|
-
|
1675
|
-
def mro(self, context=None):
|
1676
|
-
"""Get the method resolution order, using C3 linearization.
|
1677
|
-
|
1678
|
-
It returns the list of ancestors sorted by the mro.
|
1679
|
-
This will raise `NotImplementedError` for old-style classes, since
|
1680
|
-
they don't have the concept of MRO.
|
1681
|
-
"""
|
1682
|
-
if not self.newstyle:
|
1683
|
-
raise NotImplementedError(
|
1684
|
-
"Could not obtain mro for old-style classes.")
|
1685
|
-
|
1686
|
-
bases = list(self._inferred_bases(context=context))
|
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])
|
1702
|
-
_verify_duplicates_mro(unmerged_mro)
|
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)
|