Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #214 fixed pep8, pep257 and other styling errors to pass the pr… #259

Merged
merged 1 commit into from
Nov 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ Modifications to existing flavors:
- Allow passing field name as first positional argument of IBANField.
(`gh-236 <https://github.com/django/django-localflavor/pull/236>`_).
- Fixed French FRNationalIdentificationNumber bug with imaginary birth month values.
(`gh-242` <https://github.com/django/django-localflavor/pull/242>`_).
(`gh-242 <https://github.com/django/django-localflavor/pull/242>`_).
- Fixed French FRNationalIdentificationNumber bug with corsican people born after 2000.
(`gh-242` <https://github.com/django/django-localflavor/pull/242>`_).
(`gh-242 <https://github.com/django/django-localflavor/pull/242>`_).
- Fixed the translation for US state 'Georgia' from colliding with the country 'Georgia'
(`gh-250` <https://github.com/django/django-localflavor/pull/250>`_).
(`gh-250 <https://github.com/django/django-localflavor/pull/250>`_).
- Fixed the styling errors and enabled prospector
(`gh-259 <https://github.com/django/django-localflavor/pull/259>`_).

1.3 (2016-05-06)
------------------
Expand Down
4 changes: 3 additions & 1 deletion docs/extensions/promises.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

from sphinx.util.inspect import object_description

list_or_tuple = lambda x: isinstance(x, (tuple, list))

def list_or_tuple(obj):
return isinstance(obj, (tuple, list))


def lazy_repr(obj):
Expand Down
13 changes: 13 additions & 0 deletions localflavor.prospector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
inherits:
- strictness_high


pylint:
options:
max-line-length: 120

pep8:
options:
max-line-length: 120
disable:
- N802
51 changes: 22 additions & 29 deletions localflavor/ar/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
"""
AR-specific Form helpers.
"""
"""AR-specific Form helpers."""

from __future__ import unicode_literals

Expand All @@ -14,10 +12,8 @@


class ARProvinceSelect(Select):
"""
A Select widget that uses a list of Argentinean provinces/autonomous cities
as its choices.
"""
"""A Select widget that uses a list of Argentinean provinces/autonomous cities as its choices."""

def __init__(self, attrs=None):
super(ARProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)

Expand All @@ -30,6 +26,7 @@ class ARPostalCodeField(RegexField):
http://www.correoargentino.com.ar/cpa/que_es
http://www.correoargentino.com.ar/cpa/como_escribirlo
"""

default_error_messages = {
'invalid': _("Enter a postal code in the format NNNN or ANNNNAAA."),
}
Expand All @@ -51,9 +48,8 @@ def clean(self, value):


class ARDNIField(CharField):
"""
A field that validates 'Documento Nacional de Identidad' (DNI) numbers.
"""
"""A field that validates 'Documento Nacional de Identidad' (DNI) numbers."""

default_error_messages = {
'invalid': _("This field requires only numbers."),
'max_digits': _("This field requires 7 or 8 digits."),
Expand All @@ -64,9 +60,7 @@ def __init__(self, max_length=10, min_length=7, *args, **kwargs):
*args, **kwargs)

def clean(self, value):
"""
Value can be a string either in the [X]X.XXX.XXX or [X]XXXXXXX formats.
"""
"""Value can be a string either in the [X]X.XXX.XXX or [X]XXXXXXX formats."""
value = super(ARDNIField, self).clean(value)
if value in EMPTY_VALUES:
return ''
Expand All @@ -82,15 +76,17 @@ def clean(self, value):

class ARCUITField(RegexField):
"""
This field validates a CUIT (Código Único de Identificación Tributaria). A
CUIT is of the form XX-XXXXXXXX-V. The last digit is a check digit.
This field validates a CUIT (Código Único de Identificación Tributaria).

ACUIT is of the form XX-XXXXXXXX-V. The last digit is a check digit.

More info:
http://es.wikipedia.org/wiki/Clave_%C3%9Anica_de_Identificaci%C3%B3n_Tributaria

English info:
http://www.justlanded.com/english/Argentina/Argentina-Guide/Visas-Permits/Other-Legal-Documents
"""

default_error_messages = {
'invalid': _('Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'),
'checksum': _("Invalid CUIT."),
Expand All @@ -102,10 +98,7 @@ def __init__(self, max_length=None, min_length=None, *args, **kwargs):
max_length, min_length, *args, **kwargs)

def clean(self, value):
"""
Value can be either a string in the format XX-XXXXXXXX-X or an
11-digit number.
"""
"""Value can be either a string in the format XX-XXXXXXXX-X or an 11-digit number."""
value = super(ARCUITField, self).clean(value)
if value in EMPTY_VALUES:
return ''
Expand Down Expand Up @@ -141,15 +134,17 @@ def _format(self, cuit, check_digit=None):

class ARCBUField(CharField):
"""
This field validates a CBU (Clave Bancaria Uniforme). A CBU is a 22-digits long
number. The first 8 digits denote bank and branch number, plus a verifying digit.
The remaining 14 digits denote an account number, plus a verifying digit.
This field validates a CBU (Clave Bancaria Uniforme).

A CBU is a 22-digits long number. The first 8 digits denote bank and branch number,
plus a verifying digit. The remaining 14 digits denote an account number, plus a verifying digit.

More info:
https://es.wikipedia.org/wiki/Clave_Bancaria_Uniforme

.. versionadded:: 1.3
"""

default_error_messages = {
'invalid': _('Enter a valid CBU in XXXXXXXXXXXXXXXXXXXXXX format.'),
'max_length': _('CBU must be exactly 22 digits long.'),
Expand Down Expand Up @@ -179,17 +174,15 @@ def _checksum(self, value):
block_1 = value[0:8]
block_2 = value[8:22]

PONDERATOR_1 = (9, 7, 1, 3, 9, 7, 1, 3)
PONDERATOR_2 = (3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3)
ponderator_1 = (9, 7, 1, 3, 9, 7, 1, 3)
ponderator_2 = (3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3)

is_valid_1 = self._valid_block(block_1, PONDERATOR_1)
is_valid_2 = self._valid_block(block_2, PONDERATOR_2)
is_valid_1 = self._valid_block(block_1, ponderator_1)
is_valid_2 = self._valid_block(block_2, ponderator_2)
return is_valid_1 and is_valid_2

def clean(self, value):
"""
Value must be a 22 digits long number.
"""
"""Value must be a 22 digits long number."""
value = super(ARCBUField, self).clean(value)
if value in EMPTY_VALUES:
return ''
Expand Down
16 changes: 8 additions & 8 deletions localflavor/at/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
AT-specific Form helpers
"""
"""AT-specific Form helpers."""
from __future__ import unicode_literals

import re
Expand All @@ -21,6 +19,7 @@ class ATZipCodeField(RegexField):

Accepts 4 digits (first digit must be greater than 0).
"""

default_error_messages = {
'invalid': _('Enter a zip code in the format XXXX.'),
}
Expand All @@ -31,17 +30,17 @@ def __init__(self, max_length=None, min_length=None, *args, **kwargs):


class ATStateSelect(Select):
"""
A ``Select`` widget that uses a list of AT states as its choices.
"""
"""A ``Select`` widget that uses a list of AT states as its choices."""

def __init__(self, attrs=None):
super(ATStateSelect, self).__init__(attrs, choices=STATE_CHOICES)


class ATSocialSecurityNumberField(Field):
"""
Austrian Social Security numbers are composed of a 4 digits and 6 digits
field. The latter represents in most cases the person's birthdate while
Austrian Social Security numbers are composed of a 4 digits and 6 digits field.

The latter represents in most cases the person's birthdate while
the first 4 digits represent a 3-digits counter and a one-digit checksum.

The 6-digits field can also differ from the person's birthdate if the
Expand All @@ -50,6 +49,7 @@ class ATSocialSecurityNumberField(Field):
This code is based on information available on
http://de.wikipedia.org/wiki/Sozialversicherungsnummer#.C3.96sterreich
"""

default_error_messages = {
'invalid': _('Enter a valid Austrian Social Security Number in XXXX XXXXXX format.'),
}
Expand Down
32 changes: 12 additions & 20 deletions localflavor/au/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Australian-specific Form helpers
"""
"""Australian-specific Form helpers."""

from __future__ import unicode_literals

Expand All @@ -15,16 +13,17 @@
from .au_states import STATE_CHOICES
from .validators import AUBusinessNumberFieldValidator, AUTaxFileNumberFieldValidator


PHONE_DIGITS_RE = re.compile(r'^(\d{10})$')


class AUPostCodeField(RegexField):
""" Australian post code field.
"""
Australian post code field.

Assumed to be 4 digits.
Northern Territory 3-digit postcodes should have leading zero.
"""

default_error_messages = {
'invalid': _('Enter a 4 digit postcode.'),
}
Expand All @@ -40,14 +39,13 @@ class AUPhoneNumberField(CharField):

Valid numbers have ten digits.
"""

default_error_messages = {
'invalid': 'Phone numbers must contain 10 digits.',
}

def clean(self, value):
"""
Validate a phone number. Strips parentheses, whitespace and hyphens.
"""
"""Validate a phone number. Strips parentheses, whitespace and hyphens."""
super(AUPhoneNumberField, self).clean(value)
if value in EMPTY_VALUES:
return ''
Expand All @@ -59,27 +57,23 @@ def clean(self, value):


class AUStateSelect(Select):
"""
A Select widget that uses a list of Australian states/territories as its
choices.
"""
"""A Select widget that uses a list of Australian states/territories as its choices."""

def __init__(self, attrs=None):
super(AUStateSelect, self).__init__(attrs, choices=STATE_CHOICES)


class AUBusinessNumberField(CharField):
"""
A form field that validates input as an Australian Business Number (ABN)
A form field that validates input as an Australian Business Number (ABN).

.. versionadded:: 1.3
"""

default_validators = [AUBusinessNumberFieldValidator()]

def prepare_value(self, value):
"""
Format the value for display.
"""
"""Format the value for display."""
if value is None:
return value

Expand All @@ -89,17 +83,15 @@ def prepare_value(self, value):

class AUTaxFileNumberField(CharField):
"""
A form field that validates input as an Australian Tax File Number (TFN)
A form field that validates input as an Australian Tax File Number (TFN).

.. versionadded:: 1.4
"""

default_validators = [AUTaxFileNumberFieldValidator()]

def prepare_value(self, value):
"""
Format the value for display.
"""
"""Format the value for display."""
if value is None:
return value

Expand Down
31 changes: 13 additions & 18 deletions localflavor/au/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

class AUStateField(CharField):
"""
A model field that is represented with
:data:`~localflavor.au.au_states.STATE_CHOICES`` choices and
stores the three-letter Australian state abbreviation in the database.
A model field that stores the three-letter Australian state abbreviation in the database.

It is represented with :data:`~localflavor.au.au_states.STATE_CHOICES`` choices.
"""

description = _("Australian State")

def __init__(self, *args, **kwargs):
Expand All @@ -28,10 +29,11 @@ def deconstruct(self):

class AUPostCodeField(CharField):
"""
A model field that forms represent as a
:class:`~localflavor.au.forms.AUPostCodeField` field and stores the
four-digit Australian postcode in the database.
A model field that stores the four-digit Australian postcode in the database.

This field is represented by forms as a :class:`~localflavor.au.forms.AUPostCodeField` field.
"""

description = _("Australian Postcode")

def __init__(self, *args, **kwargs):
Expand All @@ -50,10 +52,8 @@ def formfield(self, **kwargs):


class AUPhoneNumberField(CharField):
"""
A model field that checks that the value is a valid Australian phone
number (ten digits).
"""
"""A model field that checks that the value is a valid Australian phone number (ten digits)."""

description = _("Australian Phone number")

def __init__(self, *args, **kwargs):
Expand All @@ -73,8 +73,7 @@ def formfield(self, **kwargs):

class AUBusinessNumberField(CharField):
"""
A model field that checks that the value is a valid Australian Business
Number (ABN).
A model field that checks that the value is a valid Australian Business Number (ABN).

.. versionadded:: 1.3
"""
Expand All @@ -98,9 +97,7 @@ def formfield(self, **kwargs):
return super(AUBusinessNumberField, self).formfield(**defaults)

def to_python(self, value):
"""
Ensure the ABN is stored without spaces.
"""
"""Ensure the ABN is stored without spaces."""
value = super(AUBusinessNumberField, self).to_python(value)

if value is not None:
Expand Down Expand Up @@ -139,9 +136,7 @@ def formfield(self, **kwargs):
return super(AUTaxFileNumberField, self).formfield(**defaults)

def to_python(self, value):
"""
Ensure the TFN is stored without spaces.
"""
"""Ensure the TFN is stored without spaces."""
value = super(AUTaxFileNumberField, self).to_python(value)

if value is not None:
Expand Down
Loading