libv8 6.7.288.46.1 → 7.3.492.27.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/ext/libv8/builder.rb +6 -2
- data/lib/libv8/version.rb +1 -1
- data/vendor/depot_tools/.gitattributes +1 -0
- data/vendor/depot_tools/.gitignore +7 -0
- data/vendor/depot_tools/CROS_OWNERS +5 -0
- data/vendor/depot_tools/OWNERS +12 -1
- data/vendor/depot_tools/PRESUBMIT.py +16 -9
- data/vendor/depot_tools/README.md +9 -2
- data/vendor/depot_tools/autoninja +14 -6
- data/vendor/depot_tools/autoninja.bat +11 -1
- data/vendor/depot_tools/autoninja.py +40 -18
- data/vendor/depot_tools/bb +12 -0
- data/vendor/depot_tools/bb.bat +7 -0
- data/vendor/depot_tools/bootstrap/win/manifest.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/win_tools.py +2 -1
- data/vendor/depot_tools/buildbucket.py +57 -4
- data/vendor/depot_tools/cipd +157 -44
- data/vendor/depot_tools/cipd.bat +51 -14
- data/vendor/depot_tools/cipd.ps1 +104 -42
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_client_version.digests +21 -0
- data/vendor/depot_tools/cipd_manifest.txt +19 -6
- data/vendor/depot_tools/cipd_manifest.versions +318 -0
- data/vendor/depot_tools/clang_format.py +4 -4
- data/vendor/depot_tools/cpplint.py +44 -199
- data/vendor/depot_tools/dart_format.py +2 -2
- data/vendor/depot_tools/detect_host_arch.py +8 -3
- data/vendor/depot_tools/download_from_google_storage.py +47 -39
- data/vendor/depot_tools/fetch.py +30 -18
- data/vendor/depot_tools/fetch_configs/android_internal.py +34 -0
- data/vendor/depot_tools/fetch_configs/chromium.py +18 -1
- data/vendor/depot_tools/fetch_configs/config_util.py +4 -2
- data/vendor/depot_tools/fetch_configs/inspector_protocol.py +40 -0
- data/vendor/depot_tools/fetch_configs/node-ci.py +41 -0
- data/vendor/depot_tools/fix_encoding.py +3 -3
- data/vendor/depot_tools/gclient +1 -1
- data/vendor/depot_tools/gclient.py +415 -198
- data/vendor/depot_tools/gclient_eval.py +220 -171
- data/vendor/depot_tools/gclient_paths.py +142 -0
- data/vendor/depot_tools/gclient_scm.py +200 -51
- data/vendor/depot_tools/gclient_utils.py +88 -191
- data/vendor/depot_tools/gerrit_client.py +13 -0
- data/vendor/depot_tools/gerrit_util.py +158 -23
- data/vendor/depot_tools/git-nav-upstream +1 -1
- data/vendor/depot_tools/git_cache.py +77 -24
- data/vendor/depot_tools/git_cl.py +705 -1099
- data/vendor/depot_tools/git_common.py +9 -6
- data/vendor/depot_tools/git_map_branches.py +19 -2
- data/vendor/depot_tools/git_nav_downstream.py +3 -4
- data/vendor/depot_tools/git_rebase_update.py +14 -0
- data/vendor/depot_tools/git_reparent_branch.py +8 -2
- data/vendor/depot_tools/gn.py +38 -3
- data/vendor/depot_tools/gsutil.py +8 -3
- data/vendor/depot_tools/gsutil.py.bat +15 -0
- data/vendor/depot_tools/gsutil.vpython +16 -0
- data/vendor/depot_tools/infra/config/OWNERS +0 -1
- data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
- data/vendor/depot_tools/lucicfg +12 -0
- data/vendor/depot_tools/lucicfg.bat +7 -0
- data/vendor/depot_tools/man/html/git-map-branches.html +34 -2
- data/vendor/depot_tools/man/html/git-new-branch.html +40 -32
- data/vendor/depot_tools/man/man1/git-map-branches.1 +24 -5
- data/vendor/depot_tools/man/man1/git-new-branch.1 +35 -27
- data/vendor/depot_tools/man/src/git-map-branches.demo.1.sh +1 -0
- data/vendor/depot_tools/man/src/git-map-branches.txt +10 -0
- data/vendor/depot_tools/man/src/git-new-branch.demo.1.sh +9 -4
- data/vendor/depot_tools/man/src/git-new-branch.txt +1 -1
- data/vendor/depot_tools/metrics.README.md +98 -0
- data/vendor/depot_tools/metrics.py +296 -0
- data/vendor/depot_tools/metrics_utils.py +303 -0
- data/vendor/depot_tools/my_activity.py +91 -29
- data/vendor/depot_tools/ninja +1 -1
- data/vendor/depot_tools/ninjalog.README.md +64 -0
- data/vendor/depot_tools/ninjalog_uploader.py +232 -0
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +116 -0
- data/vendor/depot_tools/owners.py +30 -13
- data/vendor/depot_tools/owners_finder.py +5 -2
- data/vendor/depot_tools/presubmit_canned_checks.py +188 -29
- data/vendor/depot_tools/presubmit_support.py +18 -41
- data/vendor/depot_tools/pylintrc +23 -19
- data/vendor/depot_tools/recipes/OWNERS +2 -0
- data/vendor/depot_tools/recipes/README.recipes.md +344 -151
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/OWNERS +2 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +2 -16
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +141 -99
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +6 -98
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob.json → input_commit_with_id_without_repo.json} +6 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob_empty_revision.json → multiple_patch_refs.json} +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +19 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{trychange.json → refs.json} +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +50 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +26 -28
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +13 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name.json +13 -152
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +185 -202
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +52 -157
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +5 -14
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +34 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +14 -2
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +7 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +13 -8
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.py +3 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +58 -46
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +65 -22
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +5 -2
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +62 -14
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +24 -38
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +56 -50
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.py +15 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +4 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +34 -22
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +222 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +224 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +10 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +10 -5
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +12 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +27 -11
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +12 -13
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +120 -5
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +45 -3
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +56 -4
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +6 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.py +49 -0
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +24 -13
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +13 -14
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +1 -2
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +35 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +116 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +82 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +23 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +2 -7
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +7 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +117 -8
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +7 -4
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +98 -7
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +147 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +27 -2
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/test_api.py +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/__init__.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/api.py +137 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +107 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +26 -0
- data/vendor/depot_tools/recipes/recipes.py +37 -27
- data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +7 -10
- data/vendor/depot_tools/repo +34 -8
- data/vendor/depot_tools/roll_dep.py +52 -49
- data/vendor/depot_tools/scm.py +38 -23
- data/vendor/depot_tools/setup_color.py +4 -2
- data/vendor/depot_tools/split_cl.py +32 -4
- data/vendor/depot_tools/subprocess2.py +22 -4
- data/vendor/depot_tools/third_party/httplib2/README.chromium +2 -2
- data/vendor/depot_tools/third_party/httplib2/__init__.py +242 -158
- data/vendor/depot_tools/third_party/httplib2/cacerts.txt +57 -44
- data/vendor/depot_tools/third_party/httplib2/socks.py +15 -5
- data/vendor/depot_tools/third_party/logilab/README.chromium +2 -4
- data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +2 -1
- data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +10 -5
- data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +5 -5
- data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +233 -0
- data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +82 -33
- data/vendor/depot_tools/third_party/logilab/astroid/bases.py +137 -153
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{builtin_inference.py → brain_builtin_inference.py} +117 -26
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +15 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2gi.py → brain_gi.py} +48 -8
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2mechanize.py → brain_mechanize.py} +0 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pynose.py → brain_nose.py} +4 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +62 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +76 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +44 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pysix_moves.py → brain_six.py} +28 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +65 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +473 -0
- data/vendor/depot_tools/third_party/logilab/astroid/builder.py +104 -81
- data/vendor/depot_tools/third_party/logilab/astroid/context.py +81 -0
- data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +75 -0
- data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +20 -0
- data/vendor/depot_tools/third_party/logilab/astroid/inference.py +137 -183
- data/vendor/depot_tools/third_party/logilab/astroid/manager.py +45 -169
- data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +37 -14
- data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +112 -41
- data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +243 -156
- data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +35 -22
- data/vendor/depot_tools/third_party/logilab/astroid/objects.py +186 -0
- data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +157 -102
- data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +32 -8
- data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +372 -309
- data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +652 -420
- data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +4 -21
- data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +96 -0
- data/vendor/depot_tools/third_party/logilab/astroid/util.py +89 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +19 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +20 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +1421 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +9 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +246 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +414 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +13 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +24 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +19 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +2729 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +96 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +512 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +228 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +901 -0
- data/vendor/depot_tools/third_party/pylint/README.chromium +2 -25
- data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +13 -3
- data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +1 -2
- data/vendor/depot_tools/third_party/pylint/checkers/async.py +82 -0
- data/vendor/depot_tools/third_party/pylint/checkers/base.py +893 -119
- data/vendor/depot_tools/third_party/pylint/checkers/classes.py +342 -204
- data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +51 -34
- data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +84 -47
- data/vendor/depot_tools/third_party/pylint/checkers/format.py +55 -30
- data/vendor/depot_tools/third_party/pylint/checkers/imports.py +314 -73
- data/vendor/depot_tools/third_party/pylint/checkers/logging.py +10 -8
- data/vendor/depot_tools/third_party/pylint/checkers/misc.py +2 -1
- data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +45 -48
- data/vendor/depot_tools/third_party/pylint/checkers/python3.py +31 -21
- data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +3 -3
- data/vendor/depot_tools/third_party/pylint/checkers/similar.py +4 -5
- data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +24 -10
- data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +120 -56
- data/vendor/depot_tools/third_party/pylint/checkers/strings.py +38 -35
- data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +485 -138
- data/vendor/depot_tools/third_party/pylint/checkers/utils.py +319 -142
- data/vendor/depot_tools/third_party/pylint/checkers/variables.py +329 -207
- data/vendor/depot_tools/third_party/pylint/config.py +739 -76
- data/vendor/depot_tools/third_party/pylint/epylint.py +9 -5
- data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +311 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +62 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint}/graph.py +30 -133
- data/vendor/depot_tools/third_party/pylint/gui.py +2 -2
- data/vendor/depot_tools/third_party/pylint/interfaces.py +21 -3
- data/vendor/depot_tools/third_party/pylint/lint.py +123 -140
- data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +10 -13
- data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +15 -4
- data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +372 -0
- data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +30 -7
- data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +80 -2
- data/vendor/depot_tools/third_party/{logilab/common → pylint/pyreverse}/vcgutils.py +19 -37
- data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +3 -4
- data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +34 -18
- data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +1 -1
- data/vendor/depot_tools/third_party/pylint/reporters/html.py +10 -3
- data/vendor/depot_tools/third_party/pylint/reporters/json.py +10 -4
- data/vendor/depot_tools/third_party/pylint/reporters/text.py +94 -3
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +106 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/html_writer.py +17 -57
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/nodes.py +52 -74
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/text_writer.py +14 -60
- data/vendor/depot_tools/third_party/pylint/testutils.py +22 -20
- data/vendor/depot_tools/third_party/pylint/utils.py +268 -44
- data/vendor/depot_tools/third_party/repo/progress.py +42 -0
- data/vendor/depot_tools/update_depot_tools +1 -1
- data/vendor/depot_tools/upload_metrics.py +25 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +45 -15
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +71 -24
- data/vendor/depot_tools/yapf +1 -1
- data/vendor/depot_tools/yapf.bat +1 -1
- metadata +92 -77
- data/vendor/depot_tools/git-crsync +0 -3
- data/vendor/depot_tools/infra/config/cq.cfg +0 -32
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/buildbot.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/shallow.json +0 -195
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle_deprecated.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name_no_patch.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/apply_gerrit.py +0 -33
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2pytest.py +0 -31
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2qt4.py +0 -22
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2stdlib.py +0 -334
- data/vendor/depot_tools/third_party/logilab/astroid/inspector.py +0 -273
- data/vendor/depot_tools/third_party/logilab/astroid/utils.py +0 -239
- data/vendor/depot_tools/third_party/logilab/common/LICENSE.txt +0 -339
- data/vendor/depot_tools/third_party/logilab/common/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/common/__init__.py +0 -175
- data/vendor/depot_tools/third_party/logilab/common/__pkginfo__.py +0 -57
- data/vendor/depot_tools/third_party/logilab/common/cache.py +0 -114
- data/vendor/depot_tools/third_party/logilab/common/changelog.py +0 -238
- data/vendor/depot_tools/third_party/logilab/common/clcommands.py +0 -334
- data/vendor/depot_tools/third_party/logilab/common/cli.py +0 -211
- data/vendor/depot_tools/third_party/logilab/common/compat.py +0 -78
- data/vendor/depot_tools/third_party/logilab/common/configuration.py +0 -1105
- data/vendor/depot_tools/third_party/logilab/common/contexts.py +0 -5
- data/vendor/depot_tools/third_party/logilab/common/corbautils.py +0 -117
- data/vendor/depot_tools/third_party/logilab/common/daemon.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/date.py +0 -335
- data/vendor/depot_tools/third_party/logilab/common/dbf.py +0 -231
- data/vendor/depot_tools/third_party/logilab/common/debugger.py +0 -214
- data/vendor/depot_tools/third_party/logilab/common/decorators.py +0 -281
- data/vendor/depot_tools/third_party/logilab/common/deprecation.py +0 -189
- data/vendor/depot_tools/third_party/logilab/common/fileutils.py +0 -404
- data/vendor/depot_tools/third_party/logilab/common/interface.py +0 -71
- data/vendor/depot_tools/third_party/logilab/common/logging_ext.py +0 -195
- data/vendor/depot_tools/third_party/logilab/common/modutils.py +0 -702
- data/vendor/depot_tools/third_party/logilab/common/optik_ext.py +0 -392
- data/vendor/depot_tools/third_party/logilab/common/optparser.py +0 -92
- data/vendor/depot_tools/third_party/logilab/common/proc.py +0 -277
- data/vendor/depot_tools/third_party/logilab/common/pyro_ext.py +0 -180
- data/vendor/depot_tools/third_party/logilab/common/pytest.py +0 -1199
- data/vendor/depot_tools/third_party/logilab/common/registry.py +0 -1119
- data/vendor/depot_tools/third_party/logilab/common/shellutils.py +0 -462
- data/vendor/depot_tools/third_party/logilab/common/sphinx_ext.py +0 -87
- data/vendor/depot_tools/third_party/logilab/common/sphinxutils.py +0 -122
- data/vendor/depot_tools/third_party/logilab/common/table.py +0 -929
- data/vendor/depot_tools/third_party/logilab/common/tasksqueue.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/testlib.py +0 -1392
- data/vendor/depot_tools/third_party/logilab/common/textutils.py +0 -537
- data/vendor/depot_tools/third_party/logilab/common/tree.py +0 -369
- data/vendor/depot_tools/third_party/logilab/common/umessage.py +0 -194
- data/vendor/depot_tools/third_party/logilab/common/ureports/__init__.py +0 -172
- data/vendor/depot_tools/third_party/logilab/common/ureports/docbook_writer.py +0 -140
- data/vendor/depot_tools/third_party/logilab/common/urllib2ext.py +0 -89
- data/vendor/depot_tools/third_party/logilab/common/visitor.py +0 -109
- data/vendor/depot_tools/third_party/logilab/common/xmlrpcutils.py +0 -131
- data/vendor/depot_tools/third_party/logilab/common/xmlutils.py +0 -61
@@ -20,10 +20,10 @@ import sys
|
|
20
20
|
import re
|
21
21
|
from copy import copy
|
22
22
|
|
23
|
+
import six
|
24
|
+
|
23
25
|
import astroid
|
24
|
-
from astroid import are_exclusive, builtin_lookup
|
25
26
|
from astroid import modutils
|
26
|
-
|
27
27
|
from pylint.interfaces import IAstroidChecker, INFERENCE, INFERENCE_FAILURE, HIGH
|
28
28
|
from pylint.utils import get_global_option
|
29
29
|
from pylint.checkers import BaseChecker
|
@@ -31,13 +31,28 @@ from pylint.checkers.utils import (
|
|
31
31
|
PYMETHODS, is_ancestor_name, is_builtin,
|
32
32
|
is_defined_before, is_error, is_func_default, is_func_decorator,
|
33
33
|
assign_parent, check_messages, is_inside_except, clobber_in_except,
|
34
|
-
get_all_elements, has_known_bases
|
35
|
-
|
34
|
+
get_all_elements, has_known_bases, node_ignores_exception,
|
35
|
+
is_inside_abstract_class, is_comprehension, is_iterable,
|
36
|
+
safe_infer)
|
36
37
|
|
37
38
|
SPECIAL_OBJ = re.compile("^_{2}[a-z]+_{2}$")
|
38
|
-
|
39
|
+
FUTURE = '__future__'
|
39
40
|
PY3K = sys.version_info >= (3, 0)
|
40
41
|
|
42
|
+
|
43
|
+
def _is_from_future_import(stmt, name):
|
44
|
+
"""Check if the name is a future import from another module."""
|
45
|
+
try:
|
46
|
+
module = stmt.do_import_module(stmt.modname)
|
47
|
+
except astroid.InferenceError:
|
48
|
+
return
|
49
|
+
|
50
|
+
for local_node in module.locals.get(name, []):
|
51
|
+
if (isinstance(local_node, astroid.ImportFrom)
|
52
|
+
and local_node.modname == FUTURE):
|
53
|
+
return True
|
54
|
+
|
55
|
+
|
41
56
|
def in_for_else_branch(parent, stmt):
|
42
57
|
"""Returns True if stmt in inside the else branch for a parent For stmt."""
|
43
58
|
return (isinstance(parent, astroid.For) and
|
@@ -55,7 +70,7 @@ def overridden_method(klass, name):
|
|
55
70
|
# We have found an ancestor defining <name> but it's not in the local
|
56
71
|
# dictionary. This may happen with astroid built from living objects.
|
57
72
|
return None
|
58
|
-
if isinstance(meth_node, astroid.
|
73
|
+
if isinstance(meth_node, astroid.FunctionDef):
|
59
74
|
return meth_node
|
60
75
|
return None
|
61
76
|
|
@@ -96,7 +111,7 @@ def _detect_global_scope(node, frame, defframe):
|
|
96
111
|
scope = frame.parent.scope()
|
97
112
|
if defframe and defframe.parent:
|
98
113
|
def_scope = defframe.parent.scope()
|
99
|
-
if isinstance(frame, astroid.
|
114
|
+
if isinstance(frame, astroid.FunctionDef):
|
100
115
|
# If the parent of the current node is a
|
101
116
|
# function, then it can be under its scope
|
102
117
|
# (defined in, which doesn't concern us) or
|
@@ -104,9 +119,9 @@ def _detect_global_scope(node, frame, defframe):
|
|
104
119
|
# for annotations of function arguments, they'll have
|
105
120
|
# their parent the Arguments node.
|
106
121
|
if not isinstance(node.parent,
|
107
|
-
(astroid.
|
122
|
+
(astroid.FunctionDef, astroid.Arguments)):
|
108
123
|
return False
|
109
|
-
elif any(not isinstance(f, (astroid.
|
124
|
+
elif any(not isinstance(f, (astroid.ClassDef, astroid.Module))
|
110
125
|
for f in (frame, defframe)):
|
111
126
|
# Not interested in other frames, since they are already
|
112
127
|
# not in a global scope.
|
@@ -119,7 +134,7 @@ def _detect_global_scope(node, frame, defframe):
|
|
119
134
|
# share a global scope.
|
120
135
|
parent_scope = s
|
121
136
|
while parent_scope:
|
122
|
-
if not isinstance(parent_scope, (astroid.
|
137
|
+
if not isinstance(parent_scope, (astroid.ClassDef, astroid.Module)):
|
123
138
|
break_scopes.append(parent_scope)
|
124
139
|
break
|
125
140
|
if parent_scope.parent:
|
@@ -147,12 +162,12 @@ def _fix_dot_imports(not_consumed):
|
|
147
162
|
# TODO: this should be improved in issue astroid #46
|
148
163
|
names = {}
|
149
164
|
for name, stmts in six.iteritems(not_consumed):
|
150
|
-
if any(isinstance(stmt, astroid.
|
151
|
-
and isinstance(stmt.
|
165
|
+
if any(isinstance(stmt, astroid.AssignName)
|
166
|
+
and isinstance(stmt.assign_type(), astroid.AugAssign)
|
152
167
|
for stmt in stmts):
|
153
168
|
continue
|
154
169
|
for stmt in stmts:
|
155
|
-
if not isinstance(stmt, (astroid.
|
170
|
+
if not isinstance(stmt, (astroid.ImportFrom, astroid.Import)):
|
156
171
|
continue
|
157
172
|
for imports in stmt.names:
|
158
173
|
second_name = None
|
@@ -176,7 +191,7 @@ def _find_frame_imports(name, frame):
|
|
176
191
|
*name*. Such imports can be considered assignments.
|
177
192
|
Returns True if an import for the given name was found.
|
178
193
|
"""
|
179
|
-
imports = frame.nodes_of_class((astroid.Import, astroid.
|
194
|
+
imports = frame.nodes_of_class((astroid.Import, astroid.ImportFrom))
|
180
195
|
for import_node in imports:
|
181
196
|
for import_name, import_alias in import_node.names:
|
182
197
|
# If the import uses an alias, check only that.
|
@@ -235,7 +250,7 @@ MSGS = {
|
|
235
250
|
'W0614': ('Unused import %s from wildcard import',
|
236
251
|
'unused-wildcard-import',
|
237
252
|
'Used when an imported module or variable is not used from a \
|
238
|
-
|
253
|
+
`\'from X import *\'` style import.'),
|
239
254
|
|
240
255
|
'W0621': ('Redefining name %r from outer scope (line %s)',
|
241
256
|
'redefined-outer-name',
|
@@ -255,16 +270,18 @@ MSGS = {
|
|
255
270
|
a list comprehension or a generator expression) is used outside \
|
256
271
|
the loop.'),
|
257
272
|
|
258
|
-
'
|
273
|
+
'E0632': ('Possible unbalanced tuple unpacking with '
|
259
274
|
'sequence%s: '
|
260
275
|
'left side has %d label(s), right side has %d value(s)',
|
261
276
|
'unbalanced-tuple-unpacking',
|
262
|
-
'Used when there is an unbalanced tuple unpacking in assignment'
|
277
|
+
'Used when there is an unbalanced tuple unpacking in assignment',
|
278
|
+
{'old_names': [('W0632', 'unbalanced-tuple-unpacking')]}),
|
263
279
|
|
264
|
-
'
|
280
|
+
'E0633': ('Attempting to unpack a non-sequence%s',
|
265
281
|
'unpacking-non-sequence',
|
266
282
|
'Used when something which is not '
|
267
|
-
'a sequence is used in an unpack assignment'
|
283
|
+
'a sequence is used in an unpack assignment',
|
284
|
+
{'old_names': [('W0633', 'unpacking-non-sequence')]}),
|
268
285
|
|
269
286
|
'W0640': ('Cell variable %s defined in loop',
|
270
287
|
'cell-var-from-loop',
|
@@ -313,7 +330,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
313
330
|
)
|
314
331
|
def __init__(self, linter=None):
|
315
332
|
BaseChecker.__init__(self, linter)
|
316
|
-
self._to_consume = None
|
333
|
+
self._to_consume = None # list of tuples: (to_consume:dict, consumed:dict, scope_type:str)
|
317
334
|
self._checking_mod_attr = None
|
318
335
|
|
319
336
|
def visit_module(self, node):
|
@@ -336,50 +353,61 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
336
353
|
not_consumed = self._to_consume.pop()[0]
|
337
354
|
# attempt to check for __all__ if defined
|
338
355
|
if '__all__' in node.locals:
|
339
|
-
|
340
|
-
if assigned is not astroid.YES:
|
341
|
-
for elt in getattr(assigned, 'elts', ()):
|
342
|
-
try:
|
343
|
-
elt_name = next(elt.infer())
|
344
|
-
except astroid.InferenceError:
|
345
|
-
continue
|
346
|
-
|
347
|
-
if not isinstance(elt_name, astroid.Const) \
|
348
|
-
or not isinstance(elt_name.value, six.string_types):
|
349
|
-
self.add_message('invalid-all-object',
|
350
|
-
args=elt.as_string(), node=elt)
|
351
|
-
continue
|
352
|
-
elt_name = elt_name.value
|
353
|
-
# If elt is in not_consumed, remove it from not_consumed
|
354
|
-
if elt_name in not_consumed:
|
355
|
-
del not_consumed[elt_name]
|
356
|
-
continue
|
357
|
-
if elt_name not in node.locals:
|
358
|
-
if not node.package:
|
359
|
-
self.add_message('undefined-all-variable',
|
360
|
-
args=elt_name,
|
361
|
-
node=elt)
|
362
|
-
else:
|
363
|
-
basename = os.path.splitext(node.file)[0]
|
364
|
-
if os.path.basename(basename) == '__init__':
|
365
|
-
name = node.name + "." + elt_name
|
366
|
-
try:
|
367
|
-
modutils.file_from_modpath(name.split("."))
|
368
|
-
except ImportError:
|
369
|
-
self.add_message('undefined-all-variable',
|
370
|
-
args=elt_name,
|
371
|
-
node=elt)
|
372
|
-
except SyntaxError:
|
373
|
-
# don't yield an syntax-error warning,
|
374
|
-
# because it will be later yielded
|
375
|
-
# when the file will be checked
|
376
|
-
pass
|
356
|
+
self._check_all(node, not_consumed)
|
377
357
|
# don't check unused imports in __init__ files
|
378
358
|
if not self.config.init_import and node.package:
|
379
359
|
return
|
380
360
|
|
381
361
|
self._check_imports(not_consumed)
|
382
362
|
|
363
|
+
def _check_all(self, node, not_consumed):
|
364
|
+
assigned = next(node.igetattr('__all__'))
|
365
|
+
if assigned is astroid.YES:
|
366
|
+
return
|
367
|
+
|
368
|
+
for elt in getattr(assigned, 'elts', ()):
|
369
|
+
try:
|
370
|
+
elt_name = next(elt.infer())
|
371
|
+
except astroid.InferenceError:
|
372
|
+
continue
|
373
|
+
if elt_name is astroid.YES:
|
374
|
+
continue
|
375
|
+
if not elt_name.parent:
|
376
|
+
continue
|
377
|
+
|
378
|
+
if (not isinstance(elt_name, astroid.Const)
|
379
|
+
or not isinstance(elt_name.value, six.string_types)):
|
380
|
+
self.add_message('invalid-all-object',
|
381
|
+
args=elt.as_string(), node=elt)
|
382
|
+
continue
|
383
|
+
|
384
|
+
elt_name = elt_name.value
|
385
|
+
# If elt is in not_consumed, remove it from not_consumed
|
386
|
+
if elt_name in not_consumed:
|
387
|
+
del not_consumed[elt_name]
|
388
|
+
continue
|
389
|
+
|
390
|
+
if elt_name not in node.locals:
|
391
|
+
if not node.package:
|
392
|
+
self.add_message('undefined-all-variable',
|
393
|
+
args=(elt_name, ),
|
394
|
+
node=elt)
|
395
|
+
else:
|
396
|
+
basename = os.path.splitext(node.file)[0]
|
397
|
+
if os.path.basename(basename) == '__init__':
|
398
|
+
name = node.name + "." + elt_name
|
399
|
+
try:
|
400
|
+
modutils.file_from_modpath(name.split("."))
|
401
|
+
except ImportError:
|
402
|
+
self.add_message('undefined-all-variable',
|
403
|
+
args=(elt_name, ),
|
404
|
+
node=elt)
|
405
|
+
except SyntaxError:
|
406
|
+
# don't yield an syntax-error warning,
|
407
|
+
# because it will be later yielded
|
408
|
+
# when the file will be checked
|
409
|
+
pass
|
410
|
+
|
383
411
|
def _check_imports(self, not_consumed):
|
384
412
|
local_names = _fix_dot_imports(not_consumed)
|
385
413
|
checked = set()
|
@@ -396,9 +424,9 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
396
424
|
checked.add(real_name)
|
397
425
|
|
398
426
|
if (isinstance(stmt, astroid.Import) or
|
399
|
-
(isinstance(stmt, astroid.
|
427
|
+
(isinstance(stmt, astroid.ImportFrom) and
|
400
428
|
not stmt.modname)):
|
401
|
-
if (isinstance(stmt, astroid.
|
429
|
+
if (isinstance(stmt, astroid.ImportFrom) and
|
402
430
|
SPECIAL_OBJ.search(imported_name)):
|
403
431
|
# Filter special objects (__doc__, __all__) etc.,
|
404
432
|
# because they can be imported for exporting.
|
@@ -408,11 +436,19 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
408
436
|
else:
|
409
437
|
msg = "%s imported as %s" % (imported_name, as_name)
|
410
438
|
self.add_message('unused-import', args=msg, node=stmt)
|
411
|
-
elif isinstance(stmt, astroid.
|
439
|
+
elif (isinstance(stmt, astroid.ImportFrom)
|
440
|
+
and stmt.modname != FUTURE):
|
441
|
+
|
412
442
|
if SPECIAL_OBJ.search(imported_name):
|
413
443
|
# Filter special objects (__doc__, __all__) etc.,
|
414
444
|
# because they can be imported for exporting.
|
415
445
|
continue
|
446
|
+
|
447
|
+
if _is_from_future_import(stmt, name):
|
448
|
+
# Check if the name is in fact loaded from a
|
449
|
+
# __future__ import in another module.
|
450
|
+
continue
|
451
|
+
|
416
452
|
if imported_name == '*':
|
417
453
|
self.add_message('unused-wildcard-import',
|
418
454
|
args=name, node=stmt)
|
@@ -425,12 +461,12 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
425
461
|
self.add_message('unused-import', args=msg, node=stmt)
|
426
462
|
del self._to_consume
|
427
463
|
|
428
|
-
def
|
464
|
+
def visit_classdef(self, node):
|
429
465
|
"""visit class: update consumption analysis variable
|
430
466
|
"""
|
431
467
|
self._to_consume.append((copy(node.locals), {}, 'class'))
|
432
468
|
|
433
|
-
def
|
469
|
+
def leave_classdef(self, _):
|
434
470
|
"""leave class: update consumption analysis variable
|
435
471
|
"""
|
436
472
|
# do not check for not used locals here (no sense)
|
@@ -447,12 +483,12 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
447
483
|
# do not check for not used locals here
|
448
484
|
self._to_consume.pop()
|
449
485
|
|
450
|
-
def
|
486
|
+
def visit_generatorexp(self, node):
|
451
487
|
"""visit genexpr: update consumption analysis variable
|
452
488
|
"""
|
453
489
|
self._to_consume.append((copy(node.locals), {}, 'comprehension'))
|
454
490
|
|
455
|
-
def
|
491
|
+
def leave_generatorexp(self, _):
|
456
492
|
"""leave genexpr: update consumption analysis variable
|
457
493
|
"""
|
458
494
|
# do not check for not used locals here
|
@@ -480,7 +516,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
480
516
|
# do not check for not used locals here
|
481
517
|
self._to_consume.pop()
|
482
518
|
|
483
|
-
def
|
519
|
+
def visit_functiondef(self, node):
|
484
520
|
"""visit function: update consumption analysis variable and check locals
|
485
521
|
"""
|
486
522
|
self._to_consume.append((copy(node.locals), {}, 'function'))
|
@@ -492,15 +528,22 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
492
528
|
if is_inside_except(stmt):
|
493
529
|
continue
|
494
530
|
if name in globs and not isinstance(stmt, astroid.Global):
|
495
|
-
|
531
|
+
definition = globs[name][0]
|
532
|
+
if (isinstance(definition, astroid.ImportFrom)
|
533
|
+
and definition.modname == FUTURE):
|
534
|
+
# It is a __future__ directive, not a symbol.
|
535
|
+
continue
|
536
|
+
|
537
|
+
line = definition.fromlineno
|
496
538
|
dummy_rgx = self.config.dummy_variables_rgx
|
497
539
|
if not dummy_rgx.match(name):
|
498
|
-
self.add_message('redefined-outer-name',
|
540
|
+
self.add_message('redefined-outer-name',
|
541
|
+
args=(name, line), node=stmt)
|
499
542
|
elif is_builtin(name):
|
500
543
|
# do not print Redefining builtin for additional builtins
|
501
544
|
self.add_message('redefined-builtin', args=name, node=stmt)
|
502
545
|
|
503
|
-
def
|
546
|
+
def leave_functiondef(self, node):
|
504
547
|
"""leave function: check function's locals are consumed"""
|
505
548
|
not_consumed = self._to_consume.pop()[0]
|
506
549
|
if not (self.linter.is_message_enabled('unused-variable') or
|
@@ -512,9 +555,9 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
512
555
|
# don't check arguments of abstract methods or within an interface
|
513
556
|
is_method = node.is_method()
|
514
557
|
klass = node.parent.frame()
|
515
|
-
if is_method and
|
558
|
+
if is_method and node.is_abstract():
|
516
559
|
return
|
517
|
-
if is_method and isinstance(klass, astroid.
|
560
|
+
if is_method and isinstance(klass, astroid.ClassDef):
|
518
561
|
confidence = INFERENCE if has_known_bases(klass) else INFERENCE_FAILURE
|
519
562
|
else:
|
520
563
|
confidence = HIGH
|
@@ -537,22 +580,23 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
537
580
|
stmt = stmts[0]
|
538
581
|
if isinstance(stmt, astroid.Global):
|
539
582
|
continue
|
540
|
-
if isinstance(stmt, (astroid.Import, astroid.
|
583
|
+
if isinstance(stmt, (astroid.Import, astroid.ImportFrom)):
|
541
584
|
# Detect imports, assigned to global statements.
|
542
|
-
if global_names:
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
break
|
551
|
-
elif import_name in global_names:
|
585
|
+
if not global_names:
|
586
|
+
continue
|
587
|
+
skip = False
|
588
|
+
for import_name, import_alias in stmt.names:
|
589
|
+
# If the import uses an alias, check only that.
|
590
|
+
# Otherwise, check only the import name.
|
591
|
+
if import_alias:
|
592
|
+
if import_alias in global_names:
|
552
593
|
skip = True
|
553
594
|
break
|
554
|
-
|
555
|
-
|
595
|
+
elif import_name in global_names:
|
596
|
+
skip = True
|
597
|
+
break
|
598
|
+
if skip:
|
599
|
+
continue
|
556
600
|
|
557
601
|
# care about functions with unknown argument (builtins)
|
558
602
|
if name in argnames:
|
@@ -580,8 +624,12 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
580
624
|
continue
|
581
625
|
self.add_message('unused-variable', args=name, node=stmt)
|
582
626
|
|
583
|
-
|
584
|
-
|
627
|
+
visit_asyncfunctiondef = visit_functiondef
|
628
|
+
leave_asyncfunctiondef = leave_functiondef
|
629
|
+
|
630
|
+
@check_messages('global-variable-undefined', 'global-variable-not-assigned',
|
631
|
+
'global-statement', 'global-at-module-level',
|
632
|
+
'redefined-builtin')
|
585
633
|
def visit_global(self, node):
|
586
634
|
"""check names imported exists in the global scope"""
|
587
635
|
frame = node.frame()
|
@@ -627,11 +675,11 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
627
675
|
|
628
676
|
def _check_late_binding_closure(self, node, assignment_node):
|
629
677
|
def _is_direct_lambda_call():
|
630
|
-
return (isinstance(node_scope.parent, astroid.
|
678
|
+
return (isinstance(node_scope.parent, astroid.Call)
|
631
679
|
and node_scope.parent.func is node_scope)
|
632
680
|
|
633
681
|
node_scope = node.scope()
|
634
|
-
if not isinstance(node_scope, (astroid.Lambda, astroid.
|
682
|
+
if not isinstance(node_scope, (astroid.Lambda, astroid.FunctionDef)):
|
635
683
|
return
|
636
684
|
if isinstance(node.parent, astroid.Arguments):
|
637
685
|
return
|
@@ -683,9 +731,10 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
683
731
|
_astmts.append(stmt)
|
684
732
|
astmts = _astmts
|
685
733
|
if len(astmts) == 1:
|
686
|
-
|
687
|
-
if isinstance(
|
688
|
-
|
734
|
+
assign = astmts[0].assign_type()
|
735
|
+
if (isinstance(assign, (astroid.For, astroid.Comprehension,
|
736
|
+
astroid.GeneratorExp))
|
737
|
+
and assign.statement() is not node.statement()):
|
689
738
|
self.add_message('undefined-loop-variable', args=name, node=node)
|
690
739
|
|
691
740
|
@check_messages('redefine-in-handler')
|
@@ -695,13 +744,134 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
695
744
|
if clobbering:
|
696
745
|
self.add_message('redefine-in-handler', args=args, node=name)
|
697
746
|
|
698
|
-
def
|
699
|
-
if isinstance(node.
|
747
|
+
def visit_assignname(self, node):
|
748
|
+
if isinstance(node.assign_type(), astroid.AugAssign):
|
700
749
|
self.visit_name(node)
|
701
750
|
|
702
751
|
def visit_delname(self, node):
|
703
752
|
self.visit_name(node)
|
704
753
|
|
754
|
+
@staticmethod
|
755
|
+
def _defined_in_function_definition(node, frame):
|
756
|
+
in_annotation_or_default = False
|
757
|
+
if (isinstance(frame, astroid.FunctionDef) and
|
758
|
+
node.statement() is frame):
|
759
|
+
in_annotation_or_default = (
|
760
|
+
(
|
761
|
+
PY3K and (node in frame.args.annotations
|
762
|
+
or node is frame.args.varargannotation
|
763
|
+
or node is frame.args.kwargannotation)
|
764
|
+
)
|
765
|
+
or
|
766
|
+
frame.args.parent_of(node)
|
767
|
+
)
|
768
|
+
return in_annotation_or_default
|
769
|
+
|
770
|
+
@staticmethod
|
771
|
+
def _next_to_consume(node, name, to_consume):
|
772
|
+
# mark the name as consumed if it's defined in this scope
|
773
|
+
found_node = to_consume.get(name)
|
774
|
+
if (found_node
|
775
|
+
and isinstance(node.parent, astroid.Assign)
|
776
|
+
and node.parent == found_node[0].parent):
|
777
|
+
lhs = found_node[0].parent.targets[0]
|
778
|
+
if lhs.name == name: # this name is defined in this very statement
|
779
|
+
found_node = None
|
780
|
+
return found_node
|
781
|
+
|
782
|
+
@staticmethod
|
783
|
+
def _is_variable_violation(node, name, defnode, stmt, defstmt,
|
784
|
+
frame, defframe, base_scope_type,
|
785
|
+
recursive_klass):
|
786
|
+
maybee0601 = True
|
787
|
+
annotation_return = False
|
788
|
+
if frame is not defframe:
|
789
|
+
maybee0601 = _detect_global_scope(node, frame, defframe)
|
790
|
+
elif defframe.parent is None:
|
791
|
+
# we are at the module level, check the name is not
|
792
|
+
# defined in builtins
|
793
|
+
if name in defframe.scope_attrs or astroid.builtin_lookup(name)[1]:
|
794
|
+
maybee0601 = False
|
795
|
+
else:
|
796
|
+
# we are in a local scope, check the name is not
|
797
|
+
# defined in global or builtin scope
|
798
|
+
if defframe.root().lookup(name)[1]:
|
799
|
+
maybee0601 = False
|
800
|
+
else:
|
801
|
+
# check if we have a nonlocal
|
802
|
+
if name in defframe.locals:
|
803
|
+
maybee0601 = not any(isinstance(child, astroid.Nonlocal)
|
804
|
+
and name in child.names
|
805
|
+
for child in defframe.get_children())
|
806
|
+
|
807
|
+
if (base_scope_type == 'lambda' and
|
808
|
+
isinstance(frame, astroid.ClassDef)
|
809
|
+
and name in frame.locals):
|
810
|
+
|
811
|
+
# This rule verifies that if the definition node of the
|
812
|
+
# checked name is an Arguments node and if the name
|
813
|
+
# is used a default value in the arguments defaults
|
814
|
+
# and the actual definition of the variable label
|
815
|
+
# is happening before the Arguments definition.
|
816
|
+
#
|
817
|
+
# bar = None
|
818
|
+
# foo = lambda bar=bar: bar
|
819
|
+
#
|
820
|
+
# In this case, maybee0601 should be False, otherwise
|
821
|
+
# it should be True.
|
822
|
+
maybee0601 = not (isinstance(defnode, astroid.Arguments) and
|
823
|
+
node in defnode.defaults and
|
824
|
+
frame.locals[name][0].fromlineno < defstmt.fromlineno)
|
825
|
+
elif (isinstance(defframe, astroid.ClassDef) and
|
826
|
+
isinstance(frame, astroid.FunctionDef)):
|
827
|
+
# Special rule for function return annotations,
|
828
|
+
# which uses the same name as the class where
|
829
|
+
# the function lives.
|
830
|
+
if (PY3K and node is frame.returns and
|
831
|
+
defframe.parent_of(frame.returns)):
|
832
|
+
maybee0601 = annotation_return = True
|
833
|
+
|
834
|
+
if (maybee0601 and defframe.name in defframe.locals and
|
835
|
+
defframe.locals[name][0].lineno < frame.lineno):
|
836
|
+
# Detect class assignments with the same
|
837
|
+
# name as the class. In this case, no warning
|
838
|
+
# should be raised.
|
839
|
+
maybee0601 = False
|
840
|
+
if isinstance(node.parent, astroid.Arguments):
|
841
|
+
maybee0601 = stmt.fromlineno <= defstmt.fromlineno
|
842
|
+
elif recursive_klass:
|
843
|
+
maybee0601 = True
|
844
|
+
else:
|
845
|
+
maybee0601 = maybee0601 and stmt.fromlineno <= defstmt.fromlineno
|
846
|
+
return maybee0601, annotation_return
|
847
|
+
|
848
|
+
def _ignore_class_scope(self, node, name, frame):
|
849
|
+
# Detect if we are in a local class scope, as an assignment.
|
850
|
+
# For example, the following is fair game.
|
851
|
+
#
|
852
|
+
# class A:
|
853
|
+
# b = 1
|
854
|
+
# c = lambda b=b: b * b
|
855
|
+
#
|
856
|
+
# class B:
|
857
|
+
# tp = 1
|
858
|
+
# def func(self, arg: tp):
|
859
|
+
# ...
|
860
|
+
# class C:
|
861
|
+
# tp = 2
|
862
|
+
# def func(self, arg=tp):
|
863
|
+
# ...
|
864
|
+
|
865
|
+
in_annotation_or_default = self._defined_in_function_definition(
|
866
|
+
node, frame)
|
867
|
+
if in_annotation_or_default:
|
868
|
+
frame_locals = frame.parent.scope().locals
|
869
|
+
else:
|
870
|
+
frame_locals = frame.locals
|
871
|
+
return not ((isinstance(frame, astroid.ClassDef) or
|
872
|
+
in_annotation_or_default) and
|
873
|
+
name in frame_locals)
|
874
|
+
|
705
875
|
@check_messages(*(MSGS.keys()))
|
706
876
|
def visit_name(self, node):
|
707
877
|
"""check that a name is defined if the current scope and doesn't
|
@@ -724,6 +894,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
724
894
|
start_index = len(self._to_consume) - 1
|
725
895
|
# iterates through parent scopes, from the inner to the outer
|
726
896
|
base_scope_type = self._to_consume[start_index][-1]
|
897
|
+
# pylint: disable=too-many-nested-blocks; refactoring this block is a pain.
|
727
898
|
for i in range(start_index, -1, -1):
|
728
899
|
to_consume, consumed, scope_type = self._to_consume[i]
|
729
900
|
# if the current scope is a class scope but it's not the inner
|
@@ -733,31 +904,9 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
733
904
|
# comprehension and its direct outer scope is a class
|
734
905
|
if scope_type == 'class' and i != start_index and not (
|
735
906
|
base_scope_type == 'comprehension' and i == start_index-1):
|
736
|
-
|
737
|
-
# For example, the following is fair game.
|
738
|
-
#
|
739
|
-
# class A:
|
740
|
-
# b = 1
|
741
|
-
# c = lambda b=b: b * b
|
742
|
-
#
|
743
|
-
# class B:
|
744
|
-
# tp = 1
|
745
|
-
# def func(self, arg: tp):
|
746
|
-
# ...
|
747
|
-
|
748
|
-
in_annotation = (
|
749
|
-
PY3K and isinstance(frame, astroid.Function)
|
750
|
-
and node.statement() is frame and
|
751
|
-
(node in frame.args.annotations
|
752
|
-
or node is frame.args.varargannotation
|
753
|
-
or node is frame.args.kwargannotation))
|
754
|
-
if in_annotation:
|
755
|
-
frame_locals = frame.parent.scope().locals
|
756
|
-
else:
|
757
|
-
frame_locals = frame.locals
|
758
|
-
if not ((isinstance(frame, astroid.Class) or in_annotation)
|
759
|
-
and name in frame_locals):
|
907
|
+
if self._ignore_class_scope(node, name, frame):
|
760
908
|
continue
|
909
|
+
|
761
910
|
# the name has already been consumed, only check it's not a loop
|
762
911
|
# variable used outside the loop
|
763
912
|
if name in consumed:
|
@@ -765,11 +914,10 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
765
914
|
self._check_late_binding_closure(node, defnode)
|
766
915
|
self._loopvar_name(node, name)
|
767
916
|
break
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
except KeyError:
|
917
|
+
found_node = self._next_to_consume(node, name, to_consume)
|
918
|
+
if found_node:
|
919
|
+
consumed[name] = found_node
|
920
|
+
else:
|
773
921
|
continue
|
774
922
|
# checks for use before assignment
|
775
923
|
defnode = assign_parent(to_consume[name][0])
|
@@ -777,94 +925,62 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
777
925
|
self._check_late_binding_closure(node, defnode)
|
778
926
|
defstmt = defnode.statement()
|
779
927
|
defframe = defstmt.frame()
|
780
|
-
maybee0601 = True
|
781
|
-
if not frame is defframe:
|
782
|
-
maybee0601 = _detect_global_scope(node, frame, defframe)
|
783
|
-
elif defframe.parent is None:
|
784
|
-
# we are at the module level, check the name is not
|
785
|
-
# defined in builtins
|
786
|
-
if name in defframe.scope_attrs or builtin_lookup(name)[1]:
|
787
|
-
maybee0601 = False
|
788
|
-
else:
|
789
|
-
# we are in a local scope, check the name is not
|
790
|
-
# defined in global or builtin scope
|
791
|
-
if defframe.root().lookup(name)[1]:
|
792
|
-
maybee0601 = False
|
793
|
-
else:
|
794
|
-
# check if we have a nonlocal
|
795
|
-
if name in defframe.locals:
|
796
|
-
maybee0601 = not any(isinstance(child, astroid.Nonlocal)
|
797
|
-
and name in child.names
|
798
|
-
for child in defframe.get_children())
|
799
|
-
|
800
|
-
# Handle a couple of class scoping issues.
|
801
|
-
annotation_return = False
|
802
928
|
# The class reuses itself in the class scope.
|
803
929
|
recursive_klass = (frame is defframe and
|
804
930
|
defframe.parent_of(node) and
|
805
|
-
isinstance(defframe, astroid.
|
931
|
+
isinstance(defframe, astroid.ClassDef) and
|
806
932
|
node.name == defframe.name)
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
isinstance(frame, astroid.Function)):
|
813
|
-
# Special rule for function return annotations,
|
814
|
-
# which uses the same name as the class where
|
815
|
-
# the function lives.
|
816
|
-
if (PY3K and node is frame.returns and
|
817
|
-
defframe.parent_of(frame.returns)):
|
818
|
-
maybee0601 = annotation_return = True
|
819
|
-
|
820
|
-
if (maybee0601 and defframe.name in defframe.locals and
|
821
|
-
defframe.locals[name][0].lineno < frame.lineno):
|
822
|
-
# Detect class assignments with the same
|
823
|
-
# name as the class. In this case, no warning
|
824
|
-
# should be raised.
|
825
|
-
maybee0601 = False
|
826
|
-
elif recursive_klass:
|
827
|
-
maybee0601 = True
|
828
|
-
else:
|
829
|
-
maybee0601 = maybee0601 and stmt.fromlineno <= defstmt.fromlineno
|
933
|
+
|
934
|
+
maybee0601, annotation_return = self._is_variable_violation(
|
935
|
+
node, name, defnode, stmt, defstmt,
|
936
|
+
frame, defframe,
|
937
|
+
base_scope_type, recursive_klass)
|
830
938
|
|
831
939
|
if (maybee0601
|
832
940
|
and not is_defined_before(node)
|
833
|
-
and not are_exclusive(stmt, defstmt, ('NameError',
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
941
|
+
and not astroid.are_exclusive(stmt, defstmt, ('NameError',
|
942
|
+
'Exception',
|
943
|
+
'BaseException'))):
|
944
|
+
|
945
|
+
# Used and defined in the same place, e.g `x += 1` and `del x`
|
946
|
+
defined_by_stmt = (
|
947
|
+
defstmt is stmt
|
948
|
+
and isinstance(node, (astroid.DelName, astroid.AssignName))
|
949
|
+
)
|
950
|
+
|
951
|
+
if (recursive_klass
|
952
|
+
or defined_by_stmt
|
953
|
+
or annotation_return
|
954
|
+
or isinstance(defstmt, astroid.Delete)):
|
955
|
+
if not node_ignores_exception(node, NameError):
|
956
|
+
self.add_message('undefined-variable', args=name,
|
957
|
+
node=node)
|
958
|
+
elif base_scope_type != 'lambda':
|
843
959
|
# E0601 may *not* occurs in lambda scope.
|
844
960
|
self.add_message('used-before-assignment', args=name, node=node)
|
845
|
-
elif
|
961
|
+
elif base_scope_type == 'lambda':
|
846
962
|
# E0601 can occur in class-level scope in lambdas, as in
|
847
963
|
# the following example:
|
848
964
|
# class A:
|
849
965
|
# x = lambda attr: f + attr
|
850
966
|
# f = 42
|
851
|
-
if isinstance(frame, astroid.
|
967
|
+
if isinstance(frame, astroid.ClassDef) and name in frame.locals:
|
852
968
|
if isinstance(node.parent, astroid.Arguments):
|
853
|
-
# Doing the following is fine:
|
854
|
-
# class A:
|
855
|
-
# x = 42
|
856
|
-
# y = lambda attr=x: attr
|
857
969
|
if stmt.fromlineno <= defstmt.fromlineno:
|
970
|
+
# Doing the following is fine:
|
971
|
+
# class A:
|
972
|
+
# x = 42
|
973
|
+
# y = lambda attr=x: attr
|
858
974
|
self.add_message('used-before-assignment',
|
859
975
|
args=name, node=node)
|
860
976
|
else:
|
861
977
|
self.add_message('undefined-variable',
|
862
978
|
args=name, node=node)
|
979
|
+
elif scope_type == 'lambda':
|
980
|
+
self.add_message('undefined-variable',
|
981
|
+
node=node, args=name)
|
863
982
|
|
864
|
-
|
865
|
-
del consumed[name]
|
866
|
-
else:
|
867
|
-
del to_consume[name]
|
983
|
+
del to_consume[name]
|
868
984
|
# check it's not a loop variable used outside the loop
|
869
985
|
self._loopvar_name(node, name)
|
870
986
|
break
|
@@ -873,11 +989,17 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
873
989
|
# undefined name !
|
874
990
|
if not (name in astroid.Module.scope_attrs or is_builtin(name)
|
875
991
|
or name in self.config.additional_builtins):
|
876
|
-
|
992
|
+
if not node_ignores_exception(node, NameError):
|
993
|
+
self.add_message('undefined-variable', args=name, node=node)
|
877
994
|
|
878
995
|
@check_messages('no-name-in-module')
|
879
996
|
def visit_import(self, node):
|
880
997
|
"""check modules attribute accesses"""
|
998
|
+
if node_ignores_exception(node, ImportError):
|
999
|
+
# No need to verify this, since ImportError is already
|
1000
|
+
# handled by the client code.
|
1001
|
+
return
|
1002
|
+
|
881
1003
|
for name, _ in node.names:
|
882
1004
|
parts = name.split('.')
|
883
1005
|
try:
|
@@ -887,13 +1009,17 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
887
1009
|
self._check_module_attrs(node, module, parts[1:])
|
888
1010
|
|
889
1011
|
@check_messages('no-name-in-module')
|
890
|
-
def
|
1012
|
+
def visit_importfrom(self, node):
|
891
1013
|
"""check modules attribute accesses"""
|
1014
|
+
if node_ignores_exception(node, ImportError):
|
1015
|
+
# No need to verify this, since ImportError is already
|
1016
|
+
# handled by the client code.
|
1017
|
+
return
|
1018
|
+
|
892
1019
|
name_parts = node.modname.split('.')
|
893
|
-
level = getattr(node, 'level', None)
|
894
1020
|
try:
|
895
|
-
module = node.
|
896
|
-
except Exception:
|
1021
|
+
module = node.do_import_module(name_parts[0])
|
1022
|
+
except Exception:
|
897
1023
|
return
|
898
1024
|
module = self._check_module_attrs(node, module, name_parts[1:])
|
899
1025
|
if not module:
|
@@ -913,7 +1039,8 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
913
1039
|
|
914
1040
|
targets = node.targets[0].itered()
|
915
1041
|
try:
|
916
|
-
|
1042
|
+
infered = safe_infer(node.value)
|
1043
|
+
if infered is not None:
|
917
1044
|
self._check_unpacking(infered, node, targets)
|
918
1045
|
except astroid.InferenceError:
|
919
1046
|
return
|
@@ -922,6 +1049,10 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
922
1049
|
""" Check for unbalanced tuple unpacking
|
923
1050
|
and unpacking non sequences.
|
924
1051
|
"""
|
1052
|
+
if is_inside_abstract_class(node):
|
1053
|
+
return
|
1054
|
+
if is_comprehension(node):
|
1055
|
+
return
|
925
1056
|
if infered is astroid.YES:
|
926
1057
|
return
|
927
1058
|
if (isinstance(infered.parent, astroid.Arguments) and
|
@@ -942,19 +1073,10 @@ builtins. Remember that you should avoid to define new builtins when possible.'
|
|
942
1073
|
len(targets),
|
943
1074
|
len(values)))
|
944
1075
|
# attempt to check unpacking may be possible (ie RHS is iterable)
|
945
|
-
|
946
|
-
|
947
|
-
try:
|
948
|
-
infered.getattr(meth)
|
949
|
-
break
|
950
|
-
except astroid.NotFoundError:
|
951
|
-
continue
|
952
|
-
else:
|
1076
|
+
else:
|
1077
|
+
if not is_iterable(infered):
|
953
1078
|
self.add_message('unpacking-non-sequence', node=node,
|
954
1079
|
args=(_get_unpacking_extra_info(node, infered),))
|
955
|
-
else:
|
956
|
-
self.add_message('unpacking-non-sequence', node=node,
|
957
|
-
args=(_get_unpacking_extra_info(node, infered),))
|
958
1080
|
|
959
1081
|
|
960
1082
|
def _check_module_attrs(self, node, module, module_names):
|
@@ -1017,7 +1139,7 @@ class VariablesChecker3k(VariablesChecker):
|
|
1017
1139
|
module_imports = self._to_consume[0][1]
|
1018
1140
|
consumed = {}
|
1019
1141
|
|
1020
|
-
for klass in node.nodes_of_class(astroid.
|
1142
|
+
for klass in node.nodes_of_class(astroid.ClassDef):
|
1021
1143
|
found = metaclass = name = None
|
1022
1144
|
if not klass._metaclass:
|
1023
1145
|
# Skip if this class doesn't use
|
@@ -1043,7 +1165,7 @@ class VariablesChecker3k(VariablesChecker):
|
|
1043
1165
|
name = None
|
1044
1166
|
if isinstance(klass._metaclass, astroid.Name):
|
1045
1167
|
name = klass._metaclass.name
|
1046
|
-
elif isinstance(klass._metaclass, astroid.
|
1168
|
+
elif isinstance(klass._metaclass, astroid.Attribute):
|
1047
1169
|
name = klass._metaclass.as_string()
|
1048
1170
|
|
1049
1171
|
if name is not None:
|