-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from browniebroke/feature/python2-compat
- Loading branch information
Showing
9 changed files
with
126 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django_codemod.constants import DJANGO_20, DJANGO_30 | ||
from django_codemod.visitors.base import BaseSimpleFuncRenameTransformer | ||
|
||
|
||
class LRUCacheTransformer(BaseSimpleFuncRenameTransformer): | ||
"""Resolve deprecation of ``django.utils.lru_cache.lru_cache``.""" | ||
|
||
deprecated_in = DJANGO_20 | ||
removed_in = DJANGO_30 | ||
rename_from = "django.utils.lru_cache.lru_cache" | ||
rename_to = "functools.lru_cache" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django_codemod.constants import DJANGO_20, DJANGO_30 | ||
from django_codemod.visitors.base import BaseSimpleFuncRenameTransformer | ||
|
||
|
||
class AbsPathTransformer(BaseSimpleFuncRenameTransformer): | ||
"""Resolve deprecation of ``django.utils._os.abspathu``.""" | ||
|
||
deprecated_in = DJANGO_20 | ||
removed_in = DJANGO_30 | ||
rename_from = "django.utils._os.abspathu" | ||
rename_to = "os.path.abspath" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django_codemod.visitors import LRUCacheTransformer | ||
from tests.visitors.base import BaseVisitorTest | ||
|
||
|
||
class TestLRUCacheTransformer(BaseVisitorTest): | ||
|
||
transformer = LRUCacheTransformer | ||
|
||
def test_simple_substitution(self) -> None: | ||
before = """ | ||
from django.utils.lru_cache import lru_cache | ||
result = lru_cache(content) | ||
""" | ||
after = """ | ||
from functools import lru_cache | ||
result = lru_cache(content) | ||
""" | ||
self.assertCodemod(before, after) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django_codemod.visitors import AbsPathTransformer | ||
from tests.visitors.base import BaseVisitorTest | ||
|
||
|
||
class TestAbsPathTransformer(BaseVisitorTest): | ||
|
||
transformer = AbsPathTransformer | ||
|
||
def test_simple_substitution(self) -> None: | ||
before = """ | ||
from django.utils._os import abspathu | ||
result = abspathu(content) | ||
""" | ||
after = """ | ||
from os.path import abspath | ||
result = abspath(content) | ||
""" | ||
self.assertCodemod(before, after) |