Skip to content

Commit

Permalink
Tidy project
Browse files Browse the repository at this point in the history
  • Loading branch information
lorinkoz committed Feb 23, 2021
1 parent 5808d54 commit e5ef7a9
Show file tree
Hide file tree
Showing 8 changed files with 379 additions and 101 deletions.
3 changes: 3 additions & 0 deletions .flake8
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 120
ignore = B007,B305,E203,E731,F405,W503
16 changes: 11 additions & 5 deletions .github/workflows/linters.yaml
@@ -1,18 +1,24 @@
name: linters
on: [push]
jobs:
black:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Install dependencies
- uses: actions/cache@v1
with:
path: ~/.cache/pypoetry
key: py3.6-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
py-poetry-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade black
python -m pip install poetry
python -m poetry install
- name: Run linters
run: |
black --check --exclude "migrations" django_unmigrate
uses: pre-commit/action@v2.0.0
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: black
name: black
entry: bash -c 'poetry run black $1'
language: system
types: [python]
- id: isort
name: isort
entry: bash -c 'poetry run isort $1'
language: system
types: [python]
- id: flake8
name: flake8
entry: bash -c 'poetry run flake8 $1'
language: system
types: [python]
3 changes: 1 addition & 2 deletions django_unmigrate/core.py
Expand Up @@ -3,7 +3,6 @@

from django.db import connections
from django.db.migrations.loader import MigrationLoader

from git import Repo
from git.exc import GitCommandError

Expand Down Expand Up @@ -66,7 +65,7 @@ def get_parents_from_targets(targets, database="default"):
# Since targets could be nodes of the same path, we need to discard the
# plans that are subsets of a bigger one
for target, plan in plan_dict.items():
if any([plan & iter_plan == plan for iter_plan in plan_dict.values() if iter_plan != plan]):
if any(plan & iter_plan == plan for iter_plan in plan_dict.values() if iter_plan != plan):
# This plan is a subset of an existing plan, so we ignore it
continue
final_targets.append(target)
Expand Down
1 change: 0 additions & 1 deletion django_unmigrate/settings.py
@@ -1,4 +1,3 @@
from django.conf import settings


MAIN_BRANCH = getattr(settings, "MAIN_BRANCH", "master")
8 changes: 4 additions & 4 deletions dunm_sandbox/myapp/migrations/0002_mymodel_tz_created.py
@@ -1,19 +1,19 @@
# Generated by Django 3.0.5 on 2020-05-02 01:43

from django.db import migrations, models
import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('myapp', '0001_initial'),
("myapp", "0001_initial"),
]

operations = [
migrations.AddField(
model_name='mymodel',
name='tz_created',
model_name="mymodel",
name="tz_created",
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
Expand Down

0 comments on commit e5ef7a9

Please sign in to comment.