Skip to content

Commit

Permalink
list and pre-commit support
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Sep 9, 2018
1 parent 04c7e0c commit 646b2dc
Show file tree
Hide file tree
Showing 45 changed files with 98 additions and 59 deletions.
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
exclude: '^$'
fail_fast: false
repos:
- repo: local
hooks:
- id: isort
args:
- -rc
- src/
- tests/
name: isort
entry: isort
language: system
types: [python]
- id: check-manifest
name: check-manifest
entry: check-manifest
language: system
types: [python]
files: '^$'
always_run: true

- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0
hooks:
- id: debug-statements
exclude: manage.py
- id: end-of-file-fixer
- id: flake8
exclude: docs/
args:
- src/
- tests/
- id: check-merge-conflict
- id: check-case-conflict
# - id: name-tests-test
# - id: trailing-whitespace
# - id: requirements-txt-fixer
# files: requirements-dev.txt
#- repo: git://github.com/asottile/reorder_python_imports
# rev: v1.0.1
# hooks:
# - id: reorder-python-imports
1 change: 0 additions & 1 deletion .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ source_lang = en
[main]
host = https://www.transifex.com
type = PO

2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Stefano Apostolico <[email protected]>
Stefano Apostolico <[email protected]>
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ include tox.ini
include *.py

exclude Makefile
exclude Pipfile
exclude .editorconfig
exclude .tx
exclude .pyc
exclude .pre-commit-config.yaml

recursive-exclude .tx *
recursive-exclude __pycache__ *
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "pypi"

[packages]
django = "==2.1"
pre-commit = "*"

[dev-packages]
django-reversion = "*"
Expand Down
4 changes: 2 additions & 2 deletions docs/_ext/version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import re

from docutils.parsers.rst import Directive, directives
from sphinx import addnodes, roles
from sphinx.util.console import bold
from docutils.parsers.rst import Directive, directives

# RE for option descriptions without a '--' prefix
from sphinx.writers.html import HTMLTranslator

Expand Down
1 change: 0 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,3 @@ extends :class:`django.core.signing.Signer`. If you want change your Signer you
:file:`settings.py` ::

CONCURRENCY_FIELD_SIGNER = "myapp.mysigner.DummySigner"

2 changes: 0 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ This section lists the biggest changes done on each release.
:local:

.. include:: ../CHANGES


10 changes: 7 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# -*- coding: utf-8 -*-
import sys, os
import os
import sys

from django.conf import settings

import concurrency

src = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'src'))
sys.path.insert(0, src)

from django.conf import settings

settings.configure()

import concurrency

# os.environ['DJANGO_SETTINGS_MODULE']= 'django.conf.global_settings'

Expand Down
2 changes: 0 additions & 2 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,3 @@ anyway this will NOT raise any error
.. note:: `TriggerVersionField` will be always updated


2 changes: 0 additions & 2 deletions docs/fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,3 @@ the scope of the concurrency checks.
class ConcurrencyMeta:
check_fields = ('username',)
1 change: 0 additions & 1 deletion docs/globals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
.. |concurrency| replace:: **django-concurrency**
.. |pkg| replace:: dja
.. |version| replace:: 0.1

1 change: 0 additions & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ How to run the tests
$ pip install tox
$ tox
1 change: 0 additions & 1 deletion docs/middleware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,3 @@ use :class:`concurrency.forms.ConcurrentForm`
class MyModelAdmin(ConcurrentModelAdmin):
form = forms.ModelForm # overrides default ConcurrentForm
4 changes: 3 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
import os, sys
import os
import sys

here = os.path.abspath(os.path.join(os.path.dirname(__file__)))
rel = lambda *args: os.path.join(here, *args)

Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ universal=1

[devpi:upload]
formats = bdist_wheel,sdist.tgz

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ast
import os
import re

from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand

Expand Down
1 change: 0 additions & 1 deletion src/concurrency/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re
from functools import reduce

import django
from django.contrib import admin, messages
from django.contrib.admin import helpers
from django.core.checks import Error
Expand Down
7 changes: 3 additions & 4 deletions src/concurrency/compat.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import django

# import django
# if django.VERSION <(1,9):
# from django.template.base import TemplateDoesNotExist
# else:
from django.template.exceptions import TemplateDoesNotExist # noqa - django 1.9

from django.template.exceptions import TemplateDoesNotExist # noqa
# if django.VERSION <(1,9):
# from django.core.urlresolvers import get_callable # noqa
# else:
from django.urls.utils import get_callable
from django.urls.utils import get_callable # noqa
6 changes: 4 additions & 2 deletions src/concurrency/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ def _set_attr(self, prefix_name, value):
name = prefix_name[len(self.prefix) + 1:]
if name == 'IGNORE_DEFAULT':
raise ImproperlyConfigured('IGNORE_DEFAULT has been removed in django-concurrency 1.5. '
'Use VERSION_FIELD_REQUIRED instead')
'Use VERSION_FIELD_REQUIRED instead')
elif name == 'CALLBACK':
if isinstance(value, six.string_types):
func = get_callable(value)
elif callable(value):
func = value
else:
raise ImproperlyConfigured("{} is not a valid value for `CALLBACK`. It must be a callable or a fullpath to callable. ".format(value))
raise ImproperlyConfigured(
"{} is not a valid value for `CALLBACK`. It must be a callable or a fullpath to callable. ".format(
value))
self._callback = func

setattr(self, name, value)
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys

import django

import pytest

py_impl = getattr(platform, 'python_implementation', lambda: None)
Expand Down
2 changes: 1 addition & 1 deletion tests/demoapp/demo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from functools import partial, update_wrapper
from itertools import count

import pytest
from django import db

import pytest
from demo.models import (
AutoIncConcurrentModel, ConcreteModel, CustomSaveModel, InheritedModel, ProxyModel,
SimpleConcurrentModel, TriggerConcurrentModel
Expand Down
1 change: 0 additions & 1 deletion tests/test_admin_actions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import pytest

from demo.base import SENTINEL, AdminTestCase
from demo.models import SimpleConcurrentModel
from demo.util import unique_id
Expand Down
2 changes: 1 addition & 1 deletion tests/test_admin_edit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from django.utils.translation import ugettext as _

import pytest
from demo.base import SENTINEL, AdminTestCase
from demo.models import SimpleConcurrentModel
from demo.util import nextname
Expand Down
2 changes: 1 addition & 1 deletion tests/test_admin_list_editable.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

import pytest
from django.contrib.admin.models import LogEntry
from django.contrib.admin.sites import site
from django.contrib.contenttypes.models import ContentType
from django.db import transaction
from django.utils.encoding import force_text

import pytest
from demo.base import SENTINEL, AdminTestCase
from demo.models import ListEditableConcurrentModel
from demo.util import attributes, unique_id
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from django.contrib.auth.models import Group

import pytest
from demo.models import SimpleConcurrentModel
from demo.util import nextgroup, nextname

Expand Down
2 changes: 1 addition & 1 deletion tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from django.test import override_settings

import pytest
from demo.util import concurrent_model, unique_id, with_all_models, with_std_models

from concurrency.core import _set_version
Expand Down
2 changes: 1 addition & 1 deletion tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import logging

import django
import pytest

import pytest
from demo.models import TriggerConcurrentModel

logger = logging.getLogger(__name__)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_command.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
import logging

import pytest
import six

from django.core.management import call_command

import pytest
from mock import Mock

import concurrency.management.commands.triggers as command
Expand Down
2 changes: 1 addition & 1 deletion tests/test_conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import logging

import pytest
from django.contrib.auth.models import User

import pytest
from demo.models import (
ConditionalVersionModel, ConditionalVersionModelSelfRelation,
ConditionalVersionModelWithoutMeta, ThroughRelation
Expand Down
3 changes: 2 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from django.core.exceptions import ImproperlyConfigured

import pytest

from concurrency.config import AppSettings
from concurrency.utils import fqn

Expand Down
3 changes: 1 addition & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from __future__ import absolute_import, unicode_literals

import pytest
from demo.models import SimpleConcurrentModel

from concurrency.core import _select_lock
from concurrency.exceptions import RecordModifiedError
from concurrency.utils import refetch
from demo.models import SimpleConcurrentModel


@pytest.mark.django_db
Expand All @@ -20,4 +20,3 @@ def test_select_lock(settings):

settings.CONCURRENCY_ENABLED = False
_select_lock(s1)

2 changes: 1 addition & 1 deletion tests/test_enable_disable.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
import pytest
from django.contrib.auth.models import User
from django.test.utils import override_settings

import pytest
from demo.models import AutoIncConcurrentModel, SimpleConcurrentModel
from demo.util import nextname

Expand Down
2 changes: 1 addition & 1 deletion tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
from django.forms.models import modelform_factory
from django.forms.widgets import HiddenInput, TextInput
Expand All @@ -7,6 +6,7 @@
from django.utils.encoding import smart_str
from django.utils.translation import ugettext as _

import pytest
from demo.models import Issue3TestModel, SimpleConcurrentModel

from concurrency.exceptions import VersionError
Expand Down
8 changes: 5 additions & 3 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re

import django
import pytest
from django.contrib.admin.sites import site
from django.contrib.auth.models import User
from django.core.management import call_command
Expand All @@ -13,15 +12,18 @@
from django.test.testcases import SimpleTestCase
from django.utils.encoding import force_text

from concurrency.exceptions import RecordModifiedError
import pytest
from conftest import skipIfDjangoVersion
from demo.admin import ActionsModelAdmin, admin_register
from demo.base import AdminTestCase
from demo.models import ListEditableConcurrentModel, ReversionConcurrentModel, SimpleConcurrentModel
from demo.models import (
ListEditableConcurrentModel, ReversionConcurrentModel, SimpleConcurrentModel
)
from demo.util import attributes, unique_id

from concurrency.admin import ConcurrentModelAdmin
from concurrency.config import CONCURRENCY_LIST_EDITABLE_POLICY_SILENT
from concurrency.exceptions import RecordModifiedError
from concurrency.forms import ConcurrentForm
from concurrency.templatetags.concurrency import identity
from concurrency.utils import refetch
Expand Down
Loading

0 comments on commit 646b2dc

Please sign in to comment.