Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-django-codemod for openSUSE:Factory checked in at 2022-01-11 21:19:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-django-codemod (Old) and /work/SRC/openSUSE:Factory/.python-django-codemod.new.1892 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-codemod" Tue Jan 11 21:19:45 2022 rev:5 rq:945447 version:1.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-django-codemod/python-django-codemod.changes 2022-01-07 12:47:51.619907081 +0100 +++ /work/SRC/openSUSE:Factory/.python-django-codemod.new.1892/python-django-codemod.changes 2022-01-11 21:23:57.725156860 +0100 @@ -1,0 +2,6 @@ +Mon Jan 10 22:39:58 UTC 2022 - John Vandenberg <jay...@gmail.com> + +- Update to v1.7.0 + * Avoid imports in try blocks + +------------------------------------------------------------------- Old: ---- django-codemod-1.6.6.tar.gz New: ---- django-codemod-1.7.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-django-codemod.spec ++++++ --- /var/tmp/diff_new_pack.kJq9vF/_old 2022-01-11 21:23:58.177157178 +0100 +++ /var/tmp/diff_new_pack.kJq9vF/_new 2022-01-11 21:23:58.181157181 +0100 @@ -17,10 +17,9 @@ %define skip_python2 1 -%define skip_python36 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-django-codemod -Version: 1.6.6 +Version: 1.7.0 Release: 0 Summary: Collections of libCST codemodders to upgrade Django License: MIT ++++++ django-codemod-1.6.6.tar.gz -> django-codemod-1.7.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/.github/labels.toml new/django-codemod-1.7.0/.github/labels.toml --- old/django-codemod-1.6.6/.github/labels.toml 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/.github/labels.toml 2022-01-10 18:08:51.000000000 +0100 @@ -82,3 +82,13 @@ color = "ffa663" name = "hacktoberfest" description = "Good issues for Hacktoberfest" + +[answered] +color = "0ee2b6" +name = "answered" +description = "Automatically closes as answered after a delay" + +[waiting] +color = "5f7972" +name = "waiting" +description = "Automatically closes if no answer after a delay" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/.github/workflows/ci.yml new/django-codemod-1.7.0/.github/workflows/ci.yml --- old/django-codemod-1.6.6/.github/workflows/ci.yml 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/.github/workflows/ci.yml 2022-01-10 18:08:51.000000000 +0100 @@ -81,7 +81,7 @@ # - Update CHANGELOG.md # - Update version in code # - Create git tag - # - Create Github release + # - Create GitHub release # - Publish to PyPI - name: Python Semantic Release uses: relekang/python-semantic-release@v7.23.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/.github/workflows/issue-manager.yml new/django-codemod-1.7.0/.github/workflows/issue-manager.yml --- old/django-codemod-1.6.6/.github/workflows/issue-manager.yml 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/.github/workflows/issue-manager.yml 2022-01-10 18:08:51.000000000 +0100 @@ -1,21 +1,18 @@ -# Automatically close issues that have a keyword mark (an HTML comment) -# in the last comment in the issue, by a group of predefined users, after a custom delay. -# https://github.com/tiangolo/issue-manager - -# Default config: -# <!-- issue-manager: answered --> -# Wait 10 days and comment: "Assuming the original issue was solved, it will be automatically closed now" - -# Extra config: -# '<!-- issue-manager: waiting -->' -# Wait 10 days and comment: "Automatically closing. To re-open, please provide the additional information requested" - name: Issue Manager on: - # Every day at midnight schedule: - cron: "0 0 * * *" + issue_comment: + types: + - created + issues: + types: + - labeled + pull_request_target: + types: + - labeled + workflow_dispatch: jobs: issue-manager: @@ -24,15 +21,12 @@ - uses: tiangolo/issue-manager@0.4.0 with: token: ${{ secrets.GITHUB_TOKEN }} - config: > { "answered": { - "delay": 864000, "message": "Assuming the original issue was solved, it will be automatically closed now." }, "waiting": { - "delay": 864000, "message": "Automatically closing. To re-open, please provide the additional information requested." } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/.github/workflows/semantic-release.yml new/django-codemod-1.7.0/.github/workflows/semantic-release.yml --- old/django-codemod-1.6.6/.github/workflows/semantic-release.yml 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/.github/workflows/semantic-release.yml 2022-01-10 18:08:51.000000000 +0100 @@ -17,7 +17,7 @@ # - Update CHANGELOG.md # - Update version in code # - Create git tag - # - Create Github release + # - Create GitHub release # - Publish to PyPI - name: Python Semantic Release uses: relekang/python-semantic-release@v7.23.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/.pre-commit-config.yaml new/django-codemod-1.7.0/.pre-commit-config.yaml --- old/django-codemod-1.6.6/.pre-commit-config.yaml 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/.pre-commit-config.yaml 2022-01-10 18:08:51.000000000 +0100 @@ -9,7 +9,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.1.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -22,7 +22,7 @@ - id: prettier args: ["--tab-width", "2"] - repo: https://github.com/asottile/pyupgrade - rev: v2.29.1 + rev: v2.31.0 hooks: - id: pyupgrade args: [--py3-plus] @@ -39,11 +39,11 @@ hooks: - id: flake8 - repo: https://github.com/commitizen-tools/commitizen - rev: v2.20.0 + rev: v2.20.3 hooks: - id: commitizen stages: [commit-msg] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.910-1 + rev: v0.930 hooks: - id: mypy diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/CHANGELOG.md new/django-codemod-1.7.0/CHANGELOG.md --- old/django-codemod-1.6.6/CHANGELOG.md 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/CHANGELOG.md 2022-01-10 18:08:51.000000000 +0100 @@ -2,6 +2,16 @@ <!--next-version-placeholder--> +## v1.7.0 (2022-01-10) +### Feature +* Avoid imports in try blocks ([`f6c5159`](https://github.com/browniebroke/django-codemod/commit/f6c515965714677ce2a9deff2eef1bb2232d4acb)) + +### Fix +* **deps:** Update dependency rich to v11 ([`3541992`](https://github.com/browniebroke/django-codemod/commit/354199292140c80b3b79b3f3c5b25edc951ca7fb)) + +### Documentation +* Add a note about django-upgrade in the readme ([`6bdc36d`](https://github.com/browniebroke/django-codemod/commit/6bdc36de73a7a7d06827ba16a94f8c78d07d44a8)) + ## v1.6.6 (2021-12-11) ### Fix * **deps:** Update dependency myst-parser to ^0.16.0 ([`8af7b0b`](https://github.com/browniebroke/django-codemod/commit/8af7b0bf9af0c8911b5a8773d450a70a8b24dc8e)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/README.md new/django-codemod-1.7.0/README.md --- old/django-codemod-1.6.6/README.md 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/README.md 2022-01-10 18:08:51.000000000 +0100 @@ -61,6 +61,12 @@ - This tool is best suited for Django sites, NOT for reusable Django applications. The project needs to target a single Django version, e.g. 3.1.x. - You do NOT need to install this tool as part of your project dependencies, it is a CLI tool, not a Django package to be installed in your site. +### Similar tools + +[django-upgrade](https://github.com/adamchainz/django-upgrade) is a similar tool written by Adam Johnson. It's a reimplementation taking a different approach based only on standard library module. + +django-codemod is based on [libCST](https://libcst.readthedocs.io/) (Concrete Syntax Tree), and it's a limiting factor in terms of supported Python versions as well as its speed. By using standard library modules, django-upgrade is a lot faster and is able to support the latest Python, however it requires Python 3.8+. + ## Contributors ??? Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/django_codemod/__init__.py new/django-codemod-1.7.0/django_codemod/__init__.py --- old/django-codemod-1.6.6/django_codemod/__init__.py 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/django_codemod/__init__.py 2022-01-10 18:08:51.000000000 +0100 @@ -1 +1 @@ -__version__ = "1.6.6" +__version__ = "1.7.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/django_codemod/visitors/base.py new/django-codemod-1.7.0/django_codemod/visitors/base.py --- old/django-codemod-1.6.6/django_codemod/visitors/base.py 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/django_codemod/visitors/base.py 2022-01-10 18:08:51.000000000 +0100 @@ -7,6 +7,7 @@ Attribute, BaseExpression, BaseSmallStatement, + BatchableMetadataProvider, Call, CSTNode, ImportAlias, @@ -16,15 +17,35 @@ Name, RemovalSentinel, RemoveFromParent, + Try, ) from libcst import matchers as m -from libcst.codemod import CodemodContext, ContextAwareTransformer +from libcst.codemod import CodemodContext, ContextAwareTransformer, SkipFile from libcst.codemod.visitors import AddImportsVisitor, RemoveImportsVisitor from libcst.metadata import ParentNodeProvider, Scope, ScopeProvider from django_codemod.feature_flags import REPLACE_PARENT_MODULE_IMPORTED +class IsTryImportProvider(BatchableMetadataProvider[bool]): + """ + Marks ImportFrom nodes found inside a try block. + """ + + def __init__(self) -> None: + super().__init__() + self.try_level = 0 + + def visit_Try(self, node: Try) -> None: + self.try_level += 1 + + def leave_Try(self, node: Try) -> None: + self.try_level -= 1 + + def visit_ImportFrom(self, node: ImportFrom) -> None: + self.set_metadata(node, bool(self.try_level)) + + class BaseDjCodemodTransformer(ContextAwareTransformer, ABC): deprecated_in: Tuple[int, int] removed_in: Tuple[int, int] @@ -50,6 +71,8 @@ class BaseRenameTransformer(BaseDjCodemodTransformer, ABC): """Base class to help rename or move a declaration.""" + METADATA_DEPENDENCIES = (IsTryImportProvider,) + rename_from: str rename_to: str @@ -91,10 +114,11 @@ self, original_node: ImportFrom, updated_node: ImportFrom ) -> Union[BaseSmallStatement, RemovalSentinel]: """Update import statements for matching old module name.""" + return ( self._check_import_from_exact(original_node, updated_node) or self._check_import_from_parent(original_node, updated_node) - or self._check_import_from_child(updated_node) + or self._check_import_from_child(original_node, updated_node) or updated_node ) @@ -114,7 +138,9 @@ # Check whether the exact symbol is imported if not import_from_matches(updated_node, self.old_module_parts): return None - # Match, update the node an return it + if self.get_metadata(IsTryImportProvider, original_node): + raise SkipFile + # Match, update the node and return it new_import_aliases = [] for import_alias in updated_node.names: if not self.old_name or import_alias.evaluated_name == self.old_name: @@ -162,6 +188,8 @@ # Check whether parent module is imported if not import_from_matches(updated_node, self.old_parent_module_parts): return None + if self.get_metadata(IsTryImportProvider, original_node): + raise SkipFile # Match, check imports and extract metadata for import_alias in updated_node.names: if import_alias.evaluated_name == self.old_parent_name: @@ -208,7 +236,7 @@ return updated_node def _check_import_from_child( - self, updated_node: ImportFrom + self, original_node: ImportFrom, updated_node: ImportFrom ) -> Optional[Union[BaseSmallStatement, RemovalSentinel]]: """ Check import of a member of the module being codemodded. @@ -223,6 +251,8 @@ # Check whether a member of the module is imported if not import_from_matches(updated_node, self.old_all_parts): return None + if self.get_metadata(IsTryImportProvider, original_node): + raise SkipFile # Match, add import for all imported names and remove the existing import for import_alias in updated_node.names: AddImportsVisitor.add_needed_import( @@ -260,6 +290,7 @@ def leave_Name(self, original_node: Name, updated_node: Name) -> BaseExpression: """Rename reference to the imported name.""" + matcher = self.name_matcher if ( matcher @@ -301,7 +332,7 @@ # Can't resolve scope of node -> consider no match # Might be because of one of these reasons: # - It's the same name in another scope - # - It's a attribute with the same name + # - It's an attribute with the same name # - It's a keyword argument return False return scope == self.import_scope diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/poetry.lock new/django-codemod-1.7.0/poetry.lock --- old/django-codemod-1.6.6/poetry.lock 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/poetry.lock 2022-01-10 18:08:51.000000000 +0100 @@ -351,21 +351,21 @@ [[package]] name = "mypy" -version = "0.910" +version = "0.931" description = "Optional static typing for Python" category = "dev" optional = false -python-versions = ">=3.5" +python-versions = ">=3.6" [package.dependencies] -mypy-extensions = ">=0.4.3,<0.5.0" -toml = "*" -typed-ast = {version = ">=1.4.0,<1.5.0", markers = "python_version < \"3.8\""} -typing-extensions = ">=3.7.4" +mypy-extensions = ">=0.4.3" +tomli = ">=1.1.0" +typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} +typing-extensions = ">=3.10" [package.extras] dmypy = ["psutil (>=4.0)"] -python2 = ["typed-ast (>=1.4.0,<1.5.0)"] +python2 = ["typed-ast (>=1.4.0,<2)"] [[package]] name = "mypy-extensions" @@ -879,7 +879,7 @@ [metadata] lock-version = "1.1" python-versions = "^3.6" -content-hash = "26eb733dc55f7a5b21dbc126aeb6dfc99769a4554b4ecbc7daf57ce2a38b433f" +content-hash = "26b8198029e1bee51d74f4d6c5deeeeacfe822f81f22a68c3cfb4b5c149cc21d" [metadata.files] alabaster = [ @@ -1111,29 +1111,26 @@ {file = "mdit_py_plugins-0.3.0-py3-none-any.whl", hash = "sha256:b1279701cee2dbf50e188d3da5f51fee8d78d038cdf99be57c6b9d1aa93b4073"}, ] mypy = [ - {file = "mypy-0.910-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:a155d80ea6cee511a3694b108c4494a39f42de11ee4e61e72bc424c490e46457"}, - {file = "mypy-0.910-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:b94e4b785e304a04ea0828759172a15add27088520dc7e49ceade7834275bedb"}, - {file = "mypy-0.910-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:088cd9c7904b4ad80bec811053272986611b84221835e079be5bcad029e79dd9"}, - {file = "mypy-0.910-cp35-cp35m-win_amd64.whl", hash = "sha256:adaeee09bfde366d2c13fe6093a7df5df83c9a2ba98638c7d76b010694db760e"}, - {file = "mypy-0.910-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:ecd2c3fe726758037234c93df7e98deb257fd15c24c9180dacf1ef829da5f921"}, - {file = "mypy-0.910-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:d9dd839eb0dc1bbe866a288ba3c1afc33a202015d2ad83b31e875b5905a079b6"}, - {file = "mypy-0.910-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:3e382b29f8e0ccf19a2df2b29a167591245df90c0b5a2542249873b5c1d78212"}, - {file = "mypy-0.910-cp36-cp36m-win_amd64.whl", hash = "sha256:53fd2eb27a8ee2892614370896956af2ff61254c275aaee4c230ae771cadd885"}, - {file = "mypy-0.910-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b6fb13123aeef4a3abbcfd7e71773ff3ff1526a7d3dc538f3929a49b42be03f0"}, - {file = "mypy-0.910-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:e4dab234478e3bd3ce83bac4193b2ecd9cf94e720ddd95ce69840273bf44f6de"}, - {file = "mypy-0.910-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:7df1ead20c81371ccd6091fa3e2878559b5c4d4caadaf1a484cf88d93ca06703"}, - {file = "mypy-0.910-cp37-cp37m-win_amd64.whl", hash = "sha256:0aadfb2d3935988ec3815952e44058a3100499f5be5b28c34ac9d79f002a4a9a"}, - {file = "mypy-0.910-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:ec4e0cd079db280b6bdabdc807047ff3e199f334050db5cbb91ba3e959a67504"}, - {file = "mypy-0.910-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:119bed3832d961f3a880787bf621634ba042cb8dc850a7429f643508eeac97b9"}, - {file = "mypy-0.910-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:866c41f28cee548475f146aa4d39a51cf3b6a84246969f3759cb3e9c742fc072"}, - {file = "mypy-0.910-cp38-cp38-win_amd64.whl", hash = "sha256:ceb6e0a6e27fb364fb3853389607cf7eb3a126ad335790fa1e14ed02fba50811"}, - {file = "mypy-0.910-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1a85e280d4d217150ce8cb1a6dddffd14e753a4e0c3cf90baabb32cefa41b59e"}, - {file = "mypy-0.910-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:42c266ced41b65ed40a282c575705325fa7991af370036d3f134518336636f5b"}, - {file = "mypy-0.910-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:3c4b8ca36877fc75339253721f69603a9c7fdb5d4d5a95a1a1b899d8b86a4de2"}, - {file = "mypy-0.910-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:c0df2d30ed496a08de5daed2a9ea807d07c21ae0ab23acf541ab88c24b26ab97"}, - {file = "mypy-0.910-cp39-cp39-win_amd64.whl", hash = "sha256:c6c2602dffb74867498f86e6129fd52a2770c48b7cd3ece77ada4fa38f94eba8"}, - {file = "mypy-0.910-py3-none-any.whl", hash = "sha256:ef565033fa5a958e62796867b1df10c40263ea9ded87164d67572834e57a174d"}, - {file = "mypy-0.910.tar.gz", hash = "sha256:704098302473cb31a218f1775a873b376b30b4c18229421e9e9dc8916fd16150"}, + {file = "mypy-0.931-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:3c5b42d0815e15518b1f0990cff7a705805961613e701db60387e6fb663fe78a"}, + {file = "mypy-0.931-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c89702cac5b302f0c5d33b172d2b55b5df2bede3344a2fbed99ff96bddb2cf00"}, + {file = "mypy-0.931-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:300717a07ad09525401a508ef5d105e6b56646f7942eb92715a1c8d610149714"}, + {file = "mypy-0.931-cp310-cp310-win_amd64.whl", hash = "sha256:7b3f6f557ba4afc7f2ce6d3215d5db279bcf120b3cfd0add20a5d4f4abdae5bc"}, + {file = "mypy-0.931-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:1bf752559797c897cdd2c65f7b60c2b6969ffe458417b8d947b8340cc9cec08d"}, + {file = "mypy-0.931-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:4365c60266b95a3f216a3047f1d8e3f895da6c7402e9e1ddfab96393122cc58d"}, + {file = "mypy-0.931-cp36-cp36m-win_amd64.whl", hash = "sha256:1b65714dc296a7991000b6ee59a35b3f550e0073411ac9d3202f6516621ba66c"}, + {file = "mypy-0.931-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e839191b8da5b4e5d805f940537efcaa13ea5dd98418f06dc585d2891d228cf0"}, + {file = "mypy-0.931-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:50c7346a46dc76a4ed88f3277d4959de8a2bd0a0fa47fa87a4cde36fe247ac05"}, + {file = "mypy-0.931-cp37-cp37m-win_amd64.whl", hash = "sha256:d8f1ff62f7a879c9fe5917b3f9eb93a79b78aad47b533911b853a757223f72e7"}, + {file = "mypy-0.931-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f9fe20d0872b26c4bba1c1be02c5340de1019530302cf2dcc85c7f9fc3252ae0"}, + {file = "mypy-0.931-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:1b06268df7eb53a8feea99cbfff77a6e2b205e70bf31743e786678ef87ee8069"}, + {file = "mypy-0.931-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8c11003aaeaf7cc2d0f1bc101c1cc9454ec4cc9cb825aef3cafff8a5fdf4c799"}, + {file = "mypy-0.931-cp38-cp38-win_amd64.whl", hash = "sha256:d9d2b84b2007cea426e327d2483238f040c49405a6bf4074f605f0156c91a47a"}, + {file = "mypy-0.931-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ff3bf387c14c805ab1388185dd22d6b210824e164d4bb324b195ff34e322d166"}, + {file = "mypy-0.931-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:5b56154f8c09427bae082b32275a21f500b24d93c88d69a5e82f3978018a0266"}, + {file = "mypy-0.931-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8ca7f8c4b1584d63c9a0f827c37ba7a47226c19a23a753d52e5b5eddb201afcd"}, + {file = "mypy-0.931-cp39-cp39-win_amd64.whl", hash = "sha256:74f7eccbfd436abe9c352ad9fb65872cc0f1f0a868e9d9c44db0893440f0c697"}, + {file = "mypy-0.931-py3-none-any.whl", hash = "sha256:1171f2e0859cfff2d366da2c7092b06130f232c636a3f7301e3feb8b41f6377d"}, + {file = "mypy-0.931.tar.gz", hash = "sha256:0038b21890867793581e4cb0d810829f5fd4441aa75796b53033af3aa30430ce"}, ] mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/pyproject.toml new/django-codemod-1.7.0/pyproject.toml --- old/django-codemod-1.6.6/pyproject.toml 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/pyproject.toml 2022-01-10 18:08:51.000000000 +0100 @@ -1,6 +1,6 @@ [tool.poetry] name = "django-codemod" -version = "1.6.6" +version = "1.7.0" description = "A command line tool to automatically fix Django deprecations." authors = ["Bruno Alla <alla.bru...@gmail.com>"] license = "MIT" @@ -31,7 +31,7 @@ click = "<9" libcst = "==0.3.23" pathspec = ">=0.6,<1" -rich = "<11" +rich = "<12" # Docs deps Sphinx = {version = "^4.0.0", optional = true} @@ -55,7 +55,7 @@ flake8 = "^4.0.0" pyupgrade = {version = "^2.29.1", python = "^3.6.1"} isort = {version = "^5.10.1", python = "^3.6.1"} -mypy = "^0.910" +mypy = "^0.931" [tool.semantic_release] branch = "main" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-codemod-1.6.6/tests/visitors/test_base.py new/django-codemod-1.7.0/tests/visitors/test_base.py --- old/django-codemod-1.6.6/tests/visitors/test_base.py 2021-12-11 09:26:14.000000000 +0100 +++ new/django-codemod-1.7.0/tests/visitors/test_base.py 2022-01-10 18:08:51.000000000 +0100 @@ -1,5 +1,6 @@ import pytest from libcst import matchers as m +from libcst.codemod import SkipFile from parameterized import parameterized from django_codemod.visitors.base import ( @@ -211,7 +212,7 @@ self.assertCodemod(before, after) def test_name_from_outer_scope(self) -> None: - """When import from outer scope has same name as function variable.""" + """When import from outer scope has the same name as function variable.""" before = """ from django.dummy.module import func @@ -277,6 +278,49 @@ """ self.assertCodemod(before, after) + def test_avoid_try_import(self) -> None: + before = after = """ + try: + from django.dummy.module import func + except: + from django.dummy.other_module import better_func as func + + result = func() + """ + with pytest.raises(SkipFile): + self.assertCodemod(before, after) + + @pytest.mark.usefixtures("parent_module_import_enabled") + def test_avoid_try_import_parent(self) -> None: + before = after = """ + try: + from django.dummy import module + except: + from django.dummy import other_module as module + + result = module.func() + """ + with pytest.raises(SkipFile): + self.assertCodemod(before, after) + + @pytest.mark.usefixtures("parent_module_import_enabled") + def test_parent_import_star(self) -> None: + before = after = """ + from django.dummy import * + + result = module.func() + """ + self.assertCodemod(before, after) + + @pytest.mark.usefixtures("parent_module_import_enabled") + def test_parent_import_not_matches(self) -> None: + before = after = """ + from django.ymmud import other_module + + result = other_module.other_func() + """ + self.assertCodemod(before, after) + class OtherModuleFuncRenameTransformer(BaseFuncRenameTransformer): """Transformer with different module.""" @@ -424,6 +468,18 @@ """ self.assertCodemod(before, after) + def test_avoid_try_import(self) -> None: + before = after = """ + try: + from django.dummy.module import func + except: + from django.dummy.other_module import better_func as func + + result = func() + """ + with pytest.raises(SkipFile): + self.assertCodemod(before, after) + def test_parent_module_substitution(self) -> None: before = """ from django.dummy import module