-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
F821 false positive in else when except block locals matches try block locals. #5249
Labels
bug
Something isn't working
Comments
jaraco
added a commit
to pypa/setuptools
that referenced
this issue
Jun 21, 2023
jaraco
changed the title
F821 false positive
F821 false positive in else when except block locals matches try block locals.
Jun 21, 2023
Thanks, I’ll fix this today (and will add setuptools to our ecosystem CI check). (FWIW I do recommend using a different variable name since v will be unbound after the else if you hit the except block, but we should still avoid this false positive.) |
charliermarsh
added a commit
that referenced
this issue
Jun 21, 2023
## Summary In the latest release, we made some improvements to the semantic model, but our modifications to exception-unbinding are causing some false-positives. For example: ```py try: v = 3 except ImportError as v: print(v) else: print(v) ``` In the latest release, we started unbinding `v` after the `except` handler. (We used to restore the existing binding, the `v = 3`, but this was quite complicated.) Because we don't have full branch analysis, we can't then know that `v` is still bound in the `else` branch. The solution here modifies `resolve_read` to skip-lookup when hitting unbound exceptions. So when store the "unbind" for `except ImportError as v`, we save the binding that it shadowed `v = 3`, and skip to that. Closes #5249. Closes #5250.
clrpackages
pushed a commit
to clearlinux-pkgs/pypi-setuptools
that referenced
this issue
Aug 17, 2023
…version 68.1.0 Anderson Bravalheri (46): Remove dependency on `pip-run`. Avoid pytest-perf on Cygwin Rewrite noqa directive for the bennefit of ruff Add workaround for towncrier Revert changes in _EditableFinder Reuse PathFinder to deal with fs case sensitivity in editable_wheel Add more checks for case sensitivity in editable_wheel tests Adequate tests to the latest changes in wheel 0.41.1 Allow SystemExit exceptions to pass through unless code = 0 Remove leftover variable in test_build_meta Test setup.py with sys.exit(0) only for non-legacy backend Remove unused import Exclude __pycache__ and pyc files in MANIFEST.in Exclude newsfragments and launcher directories from find_packages Ignore newsfragments by default when auto-discovering flat packages Add newsfragment Fix rst syntax in newsfragment Use default encoding when creating .pth files in editable_wheel Add newsfragment Change UTF-8 example to something simpler to parse Add regression tests for sdist Simplify handling of relative ext.depends Update changelog entry Change classification of PR from bugfix to feature Improve logic operations on path handling Use 'resolve' instead of 'abspath' Add test for auto inclusion of depends in the case of symlinks Allow symlinked Extension.depends to be auto-included by sdist Add test case for when dependency files don't exit Capture expectation about (gui-)scripts in pyproject.toml/setup.py Make sure user is notified that (gui-)scripts have to be defined in dynamic Add news fragment Remove beta warning for pyproject tool.setuptools Update docs to remove beta status for tool.setuptools Remove unused import Mention setup.py install for zip-safe and eager-resources Prefer the obsolete nomenclature Retain warning for tool.distutils (still internal/experimental) Retouch pyproject config docs Add news fragment Ignore warnings about tool.distutils Remove confusing bit of doc Refactor TestRegressions to use symlink_or_skip_test Fix tools/finalize to use NEWS instead of CHANGES (towncrier-related) Improve rendering of newsfragment Bump version: 68.0.0 → 68.1.0 Arcadiy Ivanov (1): Handle `setup.py` possibly using `sys.exit` Ashley Anderson (11): Fix sphinx-lint errors in docs Add failing test Update _EditableFinder (in _FINDER_TEMPLATE) to be case-sensitive on case-insensitive filesystems Add news fragment Remove redundant logic Ensure posix paths to enforce case-sensitivity on Windows Expand case-sensitivity tests More robust checking of path case for imports from editable installations Move _check_case within the template Fix for Python <3.10 Small refactor to fix off-by-one, lint Bart Broere (1): Fix a sentence (minor change) Dimitri Papadopoulos (1): Fix a couple typos found by codespell Hang (2): Update package_discovery.rst Update package_discovery.rst Jason R. Coombs (29): Adopt towncrier for managing changelog. Fixes jaraco/skeleton#83. ⚫ Fade to black. Use a different variable name. Fixes #3961. Workaround for astral-sh/ruff#5249. Move towncrier config to its own file. Use the default 'newsfragments' for news fragments. Use jaraco.develop.towncrier to check changes and determine the release kind. Revert to towncrier default types. Normalized headings in changelog. Remove excess config Add newsfragment Exclude jaraco.develop on cygwin Remove code reliant on bdist_wininst. Ref #3525. Replace workaround for actions/setup-python#508 with 'allow-prereleases' Remove tox boilerplate, no longer necessary with later versions of tox. Require Python 3.8 or later. Expand 'finalize' to commit and tag the change. Leverage pytest-enabler 2.2 for the default config. Update config to honor black. Apply black styling to all but vendored modules. Manually correct line too long errors. Grab workaround for pytest-dev/execnet#195. Rely on unreleased build. Workaround for pypa/build#630. Move workarounds to tox.ini to avoid url references in project metadata. Prefer 3.x for Python version (latest stable). Collapse skeleton history. Workaround for jaraco/skeleton#87. Add links to project home page and pypi. Fixes jaraco/skeleton#77. Replace redundant step names with simple 'Run'. Increase visibility of security policy. (#4) Remove TOX_WORK_DIR workaround, no longer necessary with tox 4. Ref tox-dev/tox#3050. Joyce (4): Feat: set ci-sage.yml top level as contents read feat: initial permissions to main.yml Create 3833.misc.rst Add user to changelog.d file. Oliver Mannion (1): docs: remove mention of include_package_data and package_data interaction Stefano Rivera (4): Exclude debian dirs from the default namespace search Exclude "debian" from top_level.txt. A news fragment Explain where we are ignoring Debian Thomas Kluyver (1): Remove execnet workaround ruro (14): add Extension.depends to build_ext.get_source_files add tests for Extension sdist handling add news fragment for PR improve backwards compatibility and warning messages remove test_auto_include_symlinked_depends reimplement _get_internal_depends according to the new logic remove no longer used functions in _path refactor the tests a bit move test project root to subdir, use source_dir fixture improve the touch helper function add test_symlinked_extension_sources add test_invalid_extension_depends inline is_relative_to (it's not available in Python 3.8) don't run logging verification tests under stdlib distutils wim glenn (1): Typo fix pyproject_config.rst
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometime between 0.0.265 and 0.0.274, ruff started failing on this case:
with
This issue was encountered in pypa/setuptools#3961.
The text was updated successfully, but these errors were encountered: