Skip to content

Commit

Permalink
chore: Move mixin to a module and dropped support for python3.5 (#534)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jackton1 and pre-commit-ci[bot] authored Jan 9, 2022
1 parent e3a7e01 commit e68333a
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 80 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot' && github.event.pull_request.head.repo.owner.login == github.repository_owner
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/[email protected]
Expand All @@ -30,14 +30,12 @@ jobs:
pip install -U pip
pip install flake8==3.8.4
- name: Install black
if: ${{ matrix.python-version != '3.5' }}
run: |
pip install black
run: pip install black
- name: Run Lint
uses: wearerequired/[email protected]
with:
github_token: ${{ secrets.github_token }}
black: ${{ matrix.python-version != '3.5' }}
black: true
flake8: true
git_email: "github-action[bot]@github.com"
auto_fix: ${{ matrix.python-version != '3.5' }}
auto_fix: true
13 changes: 7 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: true
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, '3.10.0-beta.1']
python-version: [3.6, 3.7, 3.8, 3.9, '3.10.0-beta.1']

steps:
- uses: actions/[email protected]
Expand Down Expand Up @@ -52,8 +52,9 @@ jobs:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
PLATFORM: ${{ matrix.platform }}

# - name: "Upload coverage to Codecov"
# uses: codecov/[email protected]
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
- name: "Upload coverage to Codecov"
if: ${{ runner.os }} == "Linux"
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion model_clone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__version__ = "2.9.6"

from model_clone.admin import CloneModelAdmin, CloneModelAdminMixin
from model_clone.mixins.clone import CloneMixin
from model_clone.mixin import CloneMixin
from model_clone.utils import create_copy_of_instance

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion model_clone/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from model_clone.mixins.clone import CloneMixin
from model_clone.mixin import CloneMixin


class CloneModelAdminMixin(object):
Expand Down
44 changes: 15 additions & 29 deletions model_clone/mixins/clone.py → model_clone/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ def check(cls, **kwargs): # pragma: no cover
"UNIQUE_DUPLICATE_SUFFIX is required.",
hint=(
"Please provide UNIQUE_DUPLICATE_SUFFIX"
+ " for {} or set USE_UNIQUE_DUPLICATE_SUFFIX=False".format(
cls.__name__
)
f" for {cls.__name__} or set USE_UNIQUE_DUPLICATE_SUFFIX=False"
),
obj=cls,
id="{}.E001".format(ModelCloneConfig.name),
id=f"{ModelCloneConfig.name}.E001",
)
)

Expand All @@ -124,13 +122,11 @@ def check(cls, **kwargs): # pragma: no cover
Error(
"UNIQUE_DUPLICATE_SUFFIX is required.",
hint=(
"Please provide DUPLICATE_SUFFIX"
+ " for {} or set USE_DUPLICATE_SUFFIX_FOR_NON_UNIQUE_FIELDS=False".format(
cls.__name__
)
f"Please provide DUPLICATE_SUFFIX for {cls.__name__} "
"or set USE_DUPLICATE_SUFFIX_FOR_NON_UNIQUE_FIELDS=False"
),
obj=cls,
id="{}.E001".format(ModelCloneConfig.name),
id=f"{ModelCloneConfig.name}.E001",
)
)

Expand All @@ -140,12 +136,10 @@ def check(cls, **kwargs): # pragma: no cover
"Conflicting configuration.",
hint=(
'Please provide either "_clone_fields"'
+ ' or "_clone_excluded_fields" for model {}'.format(
cls.__name__
)
f' or "_clone_excluded_fields" for model {cls.__name__}'
),
obj=cls,
id="{}.E002".format(ModelCloneConfig.name),
id=f"{ModelCloneConfig.name}.E002",
)
)

Expand All @@ -155,12 +149,10 @@ def check(cls, **kwargs): # pragma: no cover
"Conflicting configuration.",
hint=(
'Please provide either "_clone_m2m_fields"'
+ ' or "_clone_excluded_m2m_fields" for model {}'.format(
cls.__name__
)
f' or "_clone_excluded_m2m_fields" for model {cls.__name__}'
),
obj=cls,
id="{}.E002".format(ModelCloneConfig.name),
id=f"{ModelCloneConfig.name}.E002",
)
)

Expand All @@ -174,15 +166,11 @@ def check(cls, **kwargs): # pragma: no cover
Error(
"Conflicting configuration.",
hint=(
"Please provide either "
+ '"_clone_m2o_or_o2m_fields"'
+ " or "
+ '"_clone_excluded_m2o_or_o2m_fields" for model {}'.format(
cls.__name__
)
'Please provide either "_clone_m2o_or_o2m_fields" or '
f'"_clone_excluded_m2o_or_o2m_fields" for model {cls.__name__}'
),
obj=cls,
id="{}.E002".format(ModelCloneConfig.name),
id=f"{ModelCloneConfig.name}.E002",
)
)

Expand All @@ -191,13 +179,11 @@ def check(cls, **kwargs): # pragma: no cover
Error(
"Conflicting configuration.",
hint=(
'Please provide either "_clone_o2o_fields"'
+ ' or "_clone_excluded_o2o_fields" for model {}'.format(
cls.__name__
)
'Please provide either "_clone_o2o_fields" or '
f'"_clone_excluded_o2o_fields" for model {cls.__name__}'
),
obj=cls,
id="{}.E002".format(ModelCloneConfig.name),
id=f"{ModelCloneConfig.name}.E002",
)
)

Expand Down
1 change: 0 additions & 1 deletion model_clone/mixins/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion model_clone/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.db import models

from model_clone.mixins.clone import CloneMixin
from model_clone.mixin import CloneMixin


class CloneModel(CloneMixin, models.Model):
Expand Down
4 changes: 2 additions & 2 deletions sample/migrations/0002_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf import settings
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand Down Expand Up @@ -34,6 +34,6 @@ class Migration(migrations.Migration):
),
),
],
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
]
4 changes: 2 additions & 2 deletions sample/migrations/0005_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import django.db.models.deletion
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand Down Expand Up @@ -37,6 +37,6 @@ class Migration(migrations.Migration):
options={
"abstract": False,
},
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
]
4 changes: 2 additions & 2 deletions sample/migrations/0006_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import django.db.models.deletion
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand Down Expand Up @@ -135,6 +135,6 @@ class Migration(migrations.Migration):
"verbose_name": "Assigment",
"verbose_name_plural": "Assignments",
},
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
]
8 changes: 4 additions & 4 deletions sample/migrations/0010_furniture_house_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import django.db.models.deletion
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand All @@ -27,7 +27,7 @@ class Migration(migrations.Migration):
),
("name", models.CharField(max_length=255)),
],
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
migrations.CreateModel(
name="Room",
Expand All @@ -51,7 +51,7 @@ class Migration(migrations.Migration):
),
),
],
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
migrations.CreateModel(
name="Furniture",
Expand All @@ -75,6 +75,6 @@ class Migration(migrations.Migration):
),
),
],
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
]
4 changes: 2 additions & 2 deletions sample/migrations/0012_backcover_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import django.db.models.deletion
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand Down Expand Up @@ -36,7 +36,7 @@ class Migration(migrations.Migration):
options={
"abstract": False,
},
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
migrations.CreateModel(
name="BackCover",
Expand Down
4 changes: 2 additions & 2 deletions sample/migrations/0013_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import django.utils.timezone
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand Down Expand Up @@ -37,6 +37,6 @@ class Migration(migrations.Migration):
),
),
],
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
]
4 changes: 2 additions & 2 deletions sample/migrations/0014_auto_20210422_1449.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import django.db.models.deletion
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand All @@ -30,7 +30,7 @@ class Migration(migrations.Migration):
options={
"abstract": False,
},
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
migrations.AlterField(
model_name="assignment",
Expand Down
6 changes: 3 additions & 3 deletions sample/migrations/0015_auto_20210423_0935.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import django.db.models.deletion
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand All @@ -30,7 +30,7 @@ class Migration(migrations.Migration):
options={
"abstract": False,
},
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
migrations.CreateModel(
name="BookSaleTag",
Expand Down Expand Up @@ -60,7 +60,7 @@ class Migration(migrations.Migration):
options={
"unique_together": {("book", "sale_tag")},
},
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
migrations.AddField(
model_name="book",
Expand Down
6 changes: 3 additions & 3 deletions sample/migrations/0022_ending_sentence.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import django.db.models.deletion
from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand All @@ -27,7 +27,7 @@ class Migration(migrations.Migration):
),
("value", models.TextField()),
],
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
migrations.CreateModel(
name="Ending",
Expand All @@ -50,6 +50,6 @@ class Migration(migrations.Migration):
),
),
],
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
]
4 changes: 2 additions & 2 deletions sample_assignment/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.db import migrations, models

import model_clone.mixins.clone
import model_clone.mixin


class Migration(migrations.Migration):
Expand All @@ -26,6 +26,6 @@ class Migration(migrations.Migration):
),
("title", models.CharField(max_length=255)),
],
bases=(model_clone.mixins.clone.CloneMixin, models.Model),
bases=(model_clone.mixin.CloneMixin, models.Model),
),
]
Loading

0 comments on commit e68333a

Please sign in to comment.