Skip to content

Commit 85f3c99

Browse files
committed
Run black
1 parent de2ac16 commit 85f3c99

File tree

6 files changed

+90
-96
lines changed

6 files changed

+90
-96
lines changed

django_range_merge/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
Enables the range_merge Aggregate for Django on Postgres
33
"""
44

5-
__version__ = '0.1.0'
5+
__version__ = "0.2.0"
66

7-
default_app_config = 'django_range_merge.apps.DjangoRangeMergeConfig' # pylint: disable=invalid-name
7+
default_app_config = "django_range_merge.apps.DjangoRangeMergeConfig" # pylint: disable=invalid-name

django_range_merge/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class DjangoRangeMergeConfig(AppConfig):
1010
Configuration for the django_range_merge Django application.
1111
"""
1212

13-
name = 'django_range_merge'
13+
name = "django_range_merge"

manage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
PWD = os.path.abspath(os.path.dirname(__file__))
1010

11-
if __name__ == '__main__':
12-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_settings')
11+
if __name__ == "__main__":
12+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_settings")
1313
sys.path.append(PWD)
1414
try:
1515
from django.core.management import execute_from_command_line

runtests.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44

55
import pytest
66

7-
APP_NAME = 'django_range_merge'
8-
TESTS = 'tests'
7+
APP_NAME = "django_range_merge"
8+
TESTS = "tests"
99
PYTEST_ARGS = {
10-
'default': [
11-
TESTS, '--tb=short', '-s', '-rw'
12-
],
13-
'fast': [
14-
TESTS, '--tb=short', '-q', '-s', '-rw'
15-
],
10+
"default": [TESTS, "--tb=short", "-s", "-rw"],
11+
"fast": [TESTS, "--tb=short", "-q", "-s", "-rw"],
1612
}
1713

1814
FLAKE8_ARGS = [APP_NAME, TESTS]
@@ -26,20 +22,20 @@ def exit_on_failure(ret, message=None):
2622

2723

2824
def flake8_main(args):
29-
print('Running flake8 code linting')
30-
ret = subprocess.call(['flake8'] + args)
31-
print('flake8 failed' if ret else 'flake8 passed')
25+
print("Running flake8 code linting")
26+
ret = subprocess.call(["flake8"] + args)
27+
print("flake8 failed" if ret else "flake8 passed")
3228
return ret
3329

3430

3531
def split_class_and_function(string):
36-
class_string, function_string = string.split('.', 1)
32+
class_string, function_string = string.split(".", 1)
3733
return "%s and %s" % (class_string, function_string)
3834

3935

4036
def is_function(string):
4137
# `True` if it looks like a test function is included in the string.
42-
return string.startswith('test_') or '.test_' in string
38+
return string.startswith("test_") or ".test_" in string
4339

4440

4541
def is_class(string):
@@ -49,54 +45,49 @@ def is_class(string):
4945

5046
if __name__ == "__main__":
5147
try:
52-
sys.argv.remove('--nolint')
48+
sys.argv.remove("--nolint")
5349
except ValueError:
5450
run_flake8 = True
5551
else:
5652
run_flake8 = False
5753

5854
try:
59-
sys.argv.remove('--lintonly')
55+
sys.argv.remove("--lintonly")
6056
except ValueError:
6157
run_tests = True
6258
else:
6359
run_tests = False
6460

6561
try:
66-
sys.argv.remove('--fast')
62+
sys.argv.remove("--fast")
6763
except ValueError:
68-
style = 'default'
64+
style = "default"
6965
else:
70-
style = 'fast'
66+
style = "fast"
7167
run_flake8 = False
7268

7369
if len(sys.argv) > 1:
7470
pytest_args = sys.argv[1:]
7571
first_arg = pytest_args[0]
7672

7773
try:
78-
pytest_args.remove('--coverage')
74+
pytest_args.remove("--coverage")
7975
except ValueError:
8076
pass
8177
else:
82-
pytest_args = [
83-
'--cov-report',
84-
'xml',
85-
'--cov',
86-
APP_NAME
87-
] + pytest_args
88-
89-
if first_arg.startswith('-'):
78+
pytest_args = ["--cov-report", "xml", "--cov", APP_NAME] + pytest_args
79+
80+
if first_arg.startswith("-"):
9081
# `runtests.py [flags]`
9182
pytest_args = [TESTS] + pytest_args
9283
elif is_class(first_arg) and is_function(first_arg):
9384
# `runtests.py TestCase.test_function [flags]`
9485
expression = split_class_and_function(first_arg)
95-
pytest_args = [TESTS, '-k', expression] + pytest_args[1:]
86+
pytest_args = [TESTS, "-k", expression] + pytest_args[1:]
9687
elif is_class(first_arg) or is_function(first_arg):
9788
# `runtests.py TestCase [flags]`
9889
# `runtests.py test_function [flags]`
99-
pytest_args = [TESTS, '-k', pytest_args[0]] + pytest_args[1:]
90+
pytest_args = [TESTS, "-k", pytest_args[0]] + pytest_args[1:]
10091
else:
10192
pytest_args = PYTEST_ARGS[style]
10293

setup.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ def get_version(*file_paths):
1818
"""
1919
filename = os.path.join(os.path.dirname(__file__), *file_paths)
2020
version_file = open(filename, encoding="utf8").read()
21-
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
22-
version_file, re.M)
21+
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
2322
if version_match:
2423
return version_match.group(1)
25-
raise RuntimeError('Unable to find version string.')
24+
raise RuntimeError("Unable to find version string.")
2625

2726

2827
def load_requirements(*requirements_paths):
@@ -48,10 +47,12 @@ def add_version_constraint_or_raise(current_line, current_requirements, add_if_n
4847
# fine to add constraints to an unconstrained package,
4948
# raise an error if there are already constraints in place
5049
if existing_version_constraints and existing_version_constraints != version_constraints:
51-
raise BaseException(f'Multiple constraint definitions found for {package}:'
52-
f' "{existing_version_constraints}" and "{version_constraints}".'
53-
f'Combine constraints into one location with {package}'
54-
f'{existing_version_constraints},{version_constraints}.')
50+
raise BaseException(
51+
f"Multiple constraint definitions found for {package}:"
52+
f' "{existing_version_constraints}" and "{version_constraints}".'
53+
f"Combine constraints into one location with {package}"
54+
f"{existing_version_constraints},{version_constraints}."
55+
)
5556
if add_if_not_present or package in current_requirements:
5657
current_requirements[package] = version_constraints
5758

@@ -62,8 +63,8 @@ def add_version_constraint_or_raise(current_line, current_requirements, add_if_n
6263
for line in reqs:
6364
if is_requirement(line):
6465
add_version_constraint_or_raise(line, requirements, True)
65-
if line and line.startswith('-c') and not line.startswith('-c http'):
66-
constraint_files.add(os.path.dirname(path) + '/' + line.split('#')[0].replace('-c', '').strip())
66+
if line and line.startswith("-c") and not line.startswith("-c http"):
67+
constraint_files.add(os.path.dirname(path) + "/" + line.split("#")[0].replace("-c", "").strip())
6768

6869
# process constraint files: add constraints to existing requirements
6970
for constraint_file in constraint_files:
@@ -88,47 +89,46 @@ def is_requirement(line):
8889
return line and line.strip() and not line.startswith(("-r", "#", "-e", "git+", "-c"))
8990

9091

91-
VERSION = get_version('django_range_merge', '__init__.py')
92+
VERSION = get_version("django_range_merge", "__init__.py")
9293

93-
if sys.argv[-1] == 'tag':
94+
if sys.argv[-1] == "tag":
9495
print("Tagging the version on github:")
9596
os.system("git tag -a %s -m 'version %s'" % (VERSION, VERSION))
9697
os.system("git push --tags")
9798
sys.exit()
9899

99-
README = open(os.path.join(os.path.dirname(__file__), 'README.md'), encoding="utf8").read()
100-
CHANGELOG = open(os.path.join(os.path.dirname(__file__), 'CHANGELOG.md'), encoding="utf8").read()
100+
README = open(os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf8").read()
101+
CHANGELOG = open(os.path.join(os.path.dirname(__file__), "CHANGELOG.md"), encoding="utf8").read()
101102

102103
setup(
103-
name='django-range-merge',
104+
name="django-range-merge",
104105
version=VERSION,
105106
description="""Enables the range_merge Aggregate for Django on Postgres""",
106-
long_description=README + '\n\n' + CHANGELOG,
107-
author='Jack Linke',
108-
author_email='[email protected]',
109-
url='https://github.com/jacklinke/django-range-merge',
107+
long_description=README + "\n\n" + CHANGELOG,
108+
author="Jack Linke",
109+
author_email="[email protected]",
110+
url="https://github.com/jacklinke/django-range-merge",
110111
packages=find_packages(
111-
include=['django_range_merge', 'django_range_merge.*'],
112+
include=["django_range_merge", "django_range_merge.*"],
112113
exclude=["*tests"],
113114
),
114-
115115
include_package_data=True,
116116
# install_requires=load_requirements('requirements-dev.txt'),
117117
python_requires=">=3.8",
118118
zip_safe=False,
119-
keywords='Postgres django range fields aggregate',
119+
keywords="Postgres django range fields aggregate",
120120
classifiers=[
121-
'Development Status :: 3 - Alpha',
122-
'Framework :: Django',
123-
'Framework :: Django :: 3.2',
124-
'Framework :: Django :: 4.0',
125-
'Framework :: Django :: 4.1',
126-
'Intended Audience :: Developers',
127-
'License :: Other/Proprietary License',
128-
'Natural Language :: English',
129-
'Programming Language :: Python :: 3',
130-
'Programming Language :: Python :: 3.8',
131-
'Programming Language :: Python :: 3.9',
132-
'Programming Language :: Python :: 3.10',
121+
"Development Status :: 3 - Alpha",
122+
"Framework :: Django",
123+
"Framework :: Django :: 3.2",
124+
"Framework :: Django :: 4.0",
125+
"Framework :: Django :: 4.1",
126+
"Intended Audience :: Developers",
127+
"License :: Other/Proprietary License",
128+
"Natural Language :: English",
129+
"Programming Language :: Python :: 3",
130+
"Programming Language :: Python :: 3.8",
131+
"Programming Language :: Python :: 3.9",
132+
"Programming Language :: Python :: 3.10",
133133
],
134134
)

test_settings.py

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,52 @@ def root(*args):
1414
"""
1515
return join(abspath(dirname(__file__)), *args)
1616

17+
1718
USE_TZ = True
1819

1920
DATABASES = {
20-
'default': {
21-
'ENGINE': 'django.db.backends.sqlite3',
22-
'NAME': 'default.db',
23-
'USER': '',
24-
'PASSWORD': '',
25-
'HOST': '',
26-
'PORT': '',
21+
"default": {
22+
"ENGINE": "django.db.backends.sqlite3",
23+
"NAME": "default.db",
24+
"USER": "",
25+
"PASSWORD": "",
26+
"HOST": "",
27+
"PORT": "",
2728
}
2829
}
2930

3031
INSTALLED_APPS = (
31-
'django.contrib.admin',
32-
'django.contrib.auth',
33-
'django.contrib.contenttypes',
34-
'django.contrib.messages',
35-
'django.contrib.sessions',
36-
'django_range_merge',
32+
"django.contrib.admin",
33+
"django.contrib.auth",
34+
"django.contrib.contenttypes",
35+
"django.contrib.messages",
36+
"django.contrib.sessions",
37+
"django_range_merge",
3738
)
3839

3940
LOCALE_PATHS = [
40-
root('django_range_merge', 'conf', 'locale'),
41+
root("django_range_merge", "conf", "locale"),
4142
]
4243

43-
ROOT_URLCONF = 'django_range_merge.urls'
44+
ROOT_URLCONF = "django_range_merge.urls"
4445

45-
SECRET_KEY = 'insecure-secret-key'
46+
SECRET_KEY = "insecure-secret-key"
4647

4748
MIDDLEWARE = (
48-
'django.contrib.auth.middleware.AuthenticationMiddleware',
49-
'django.contrib.messages.middleware.MessageMiddleware',
50-
'django.contrib.sessions.middleware.SessionMiddleware',
49+
"django.contrib.auth.middleware.AuthenticationMiddleware",
50+
"django.contrib.messages.middleware.MessageMiddleware",
51+
"django.contrib.sessions.middleware.SessionMiddleware",
5152
)
5253

53-
TEMPLATES = [{
54-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
55-
'APP_DIRS': False,
56-
'OPTIONS': {
57-
'context_processors': [
58-
'django.contrib.auth.context_processors.auth', # this is required for admin
59-
'django.contrib.messages.context_processors.messages', # this is required for admin
60-
],
61-
},
62-
}]
54+
TEMPLATES = [
55+
{
56+
"BACKEND": "django.template.backends.django.DjangoTemplates",
57+
"APP_DIRS": False,
58+
"OPTIONS": {
59+
"context_processors": [
60+
"django.contrib.auth.context_processors.auth", # this is required for admin
61+
"django.contrib.messages.context_processors.messages", # this is required for admin
62+
],
63+
},
64+
}
65+
]

0 commit comments

Comments
 (0)