Skip to content

Commit 402eba0

Browse files
committed
Formatting
1 parent 7432981 commit 402eba0

26 files changed

+376
-181
lines changed

.pep8speaks.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
pycodestyle:
22
max-line-length: 100 # Default is 79 in PEP8
33
ignore: # Errors and warnings to ignore
4-
- E401 # multiple imports on one line
54
exclude:
65
- "./docs/*"
76
- "*/build/*"
87
- "*/migrations/*"
8+
9+
# E401: multiple imports on one line

.travis/install.sh

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ export COMMIT_MSG=$(git show HEAD^2 -s)
55
export PULP_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulp\/pull\/(\d+)' | awk -F'/' '{print $7}')
66
export PULP_SMASH_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/PulpQE\/pulp-smash\/pull\/(\d+)' | awk -F'/' '{print $7}')
77

8-
# temporary workaround until a newer RQ release is available
9-
pip install git+https://github.com/rq/rq.git@3133d94b58e59cb86e8f4677492d48b2addcf5f8
10-
118
pip install -r test_requirements.txt
129

1310
cd .. && git clone https://github.com/pulp/pulp.git

docs/conf.py

+20-15
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@
186186
# Grouping the document tree into LaTeX files. List of tuples
187187
# (source start file, target name, title, author, documentclass [howto/manual]).
188188
latex_documents = [
189-
('index', 'PulpPythonSupport.tex', u'Pulp Python Support Documentation',
190-
u'Pulp Project', 'manual'),
189+
('index', 'PulpPythonSupport.tex', u'Pulp Python Support Documentation',
190+
u'Pulp Project', 'manual'),
191191
]
192192

193193
# The name of an image file (relative to this directory) to place at the top of
@@ -217,7 +217,7 @@
217217
# (source start file, name, description, authors, manual section).
218218
man_pages = [
219219
('index', 'pulppythonsupport', u'Pulp Python Support Documentation',
220-
[u'Pulp Project'], 1)
220+
[u'Pulp Project'], 1),
221221
]
222222

223223
# If true, show URL addresses after external links.
@@ -230,9 +230,9 @@
230230
# (source start file, target name, title, author,
231231
# dir menu entry, description, category)
232232
texinfo_documents = [
233-
('index', 'PulpPythonSupport', u'Pulp Python Support Documentation',
234-
u'Pulp Project', 'PulpPythonSupport', 'One line description of project.',
235-
'Miscellaneous'),
233+
('index', 'PulpPythonSupport', u'Pulp Python Support Documentation',
234+
u'Pulp Project', 'PulpPythonSupport', 'One line description of project.',
235+
'Miscellaneous'),
236236
]
237237

238238
# Documents to append as an appendix to all manuals.
@@ -244,12 +244,17 @@
244244
# How to display URL addresses: 'footnote', 'no', or 'inline'.
245245
#texinfo_show_urls = 'footnote'
246246

247-
extlinks = {'redmine': ('https://pulp.plan.io/issues/%s', '#'),
248-
'fixedbugs_pulp_python': ('https://pulp.plan.io/projects/pulp_python/issues?c%%5B%%5D='
249-
'tracker&c%%5B%%5D=status&c%%5B%%5D=priority&c%%5B%%5D=cf_5&'
250-
'c%%5B%%5D=subject&c%%5B%%5D=author&c%%5B%%5D=assigned_to&c%'
251-
'%5B%%5D=cf_3&f%%5B%%5D=cf_11&f%%5B%%5D=tracker_id&f%%5B%%5D'
252-
'=&group_by=&op%%5Bcf_11%%5D=%%3D&op%%5Btracker_id%%5D=%%3D&'
253-
'set_filter=1&sort=priority%%3Adesc%%2Ccf_5%%3Adesc%%2Cstatu'
254-
's&utf8=%%E2%%9C%%93&v%%5Bcf_11%%5D%%5B%%5D=%s&v%%5Btracker_'
255-
'id%%5D%%5B%%5D=1', 'bugs fixed in '),}
247+
extlinks = {
248+
"redmine": ("https://pulp.plan.io/issues/%s", "#"),
249+
"fixedbugs_pulp_python": (
250+
"https://pulp.plan.io/projects/pulp_python/issues?c%%5B%%5D="
251+
"tracker&c%%5B%%5D=status&c%%5B%%5D=priority&c%%5B%%5D=cf_5&"
252+
"c%%5B%%5D=subject&c%%5B%%5D=author&c%%5B%%5D=assigned_to&c%"
253+
"%5B%%5D=cf_3&f%%5B%%5D=cf_11&f%%5B%%5D=tracker_id&f%%5B%%5D"
254+
"=&group_by=&op%%5Bcf_11%%5D=%%3D&op%%5Btracker_id%%5D=%%3D&"
255+
"set_filter=1&sort=priority%%3Adesc%%2Ccf_5%%3Adesc%%2Cstatu"
256+
"s&utf8=%%E2%%9C%%93&v%%5Bcf_11%%5D%%5B%%5D=%s&v%%5Btracker_"
257+
"id%%5D%%5B%%5D=1",
258+
"bugs fixed in ",
259+
),
260+
}

flake8.cfg

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
[flake8]
22
exclude = ./docs/*,*/migrations/*
3-
# E401: multiple imports on one line
4-
ignore = E401
3+
ignore = Q000,D100,D104,D106,D200,D402
54
max-line-length = 100
5+
6+
# Flake8-quotes extension codes
7+
# -----------------------------
8+
# Q000: double or single quotes only, default is double (don't want to enforce this)
9+
10+
# Flake8-docstring extension codes
11+
# --------------------------------
12+
# D100: missing docstring in public module
13+
# D104: missing docstring in public package
14+
# D106: missing docstring in public nested class (complains about "class Meta:" and documenting those is silly)
15+
# D200: one-line docstring should fit on one line with quotes
16+
# D402: first line should not be the function’s “signature” (false positives)

pulp_python/app/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class PulpPythonPluginAppConfig(PulpPluginAppConfig):
55
"""
6-
Entry point for pulp_python plugin
6+
Entry point for pulp_python plugin.
77
"""
88

99
name = 'pulp_python.app'

pulp_python/app/models.py

+51-29
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
from django.db import models
44

5-
from pulpcore.plugin.models import Content, Remote, Model, Publisher
5+
from pulpcore.plugin.models import Content, Model, Publisher, Remote
66

77
log = getLogger(__name__)
88

99

10-
PACKAGE_TYPES = (("bdist_dmg", "bdist_dmg"), ("bdist_dumb", "bdist_dumb"),
11-
("bdist_egg", "bdist_egg"), ("bdist_msi", "bdist_msi"),
12-
("bdist_rpm", "bdist_rpm"), ("bdist_wheel", "bdist_wheel"),
13-
("bdist_wininst", "bdist_wininst"), ("sdist", "sdist"))
10+
PACKAGE_TYPES = (
11+
("bdist_dmg", "bdist_dmg"),
12+
("bdist_dumb", "bdist_dumb"),
13+
("bdist_egg", "bdist_egg"),
14+
("bdist_msi", "bdist_msi"),
15+
("bdist_rpm", "bdist_rpm"),
16+
("bdist_wheel", "bdist_wheel"),
17+
("bdist_wininst", "bdist_wininst"),
18+
("sdist", "sdist"),
19+
)
1420

1521

1622
class Classifier(Model):
1723
"""
18-
Custom tags for classifier
24+
Custom tags for classifier.
1925
2026
Fields:
2127
@@ -25,25 +31,30 @@ class Classifier(Model):
2531
2632
python_package_content (models.ForeignKey): The PythonPackageContent this classifier
2733
is associated with.
28-
2934
"""
3035

3136
name = models.TextField()
32-
python_package_content = models.ForeignKey("PythonPackageContent", related_name="classifiers",
33-
related_query_name="classifier",
34-
on_delete=models.CASCADE)
37+
python_package_content = models.ForeignKey(
38+
"PythonPackageContent",
39+
related_name="classifiers",
40+
related_query_name="classifier",
41+
on_delete=models.CASCADE
42+
)
3543

3644

3745
class DistributionDigest(Model):
3846
"""
3947
A model of digests on an individual distribution.
4048
"""
49+
4150
type = models.TextField()
4251
digest = models.TextField()
43-
project_specifier = models.ForeignKey("ProjectSpecifier",
44-
related_name="digests",
45-
related_query_name="distributiondigest",
46-
on_delete=models.CASCADE)
52+
project_specifier = models.ForeignKey(
53+
"ProjectSpecifier",
54+
related_name="digests",
55+
related_query_name="distributiondigest",
56+
on_delete=models.CASCADE
57+
)
4758

4859

4960
class ProjectSpecifier(Model):
@@ -69,16 +80,20 @@ class ProjectSpecifier(Model):
6980

7081
name = models.TextField()
7182
version_specifier = models.TextField(blank=True, default="")
72-
remote = models.ForeignKey("PythonRemote",
73-
related_name="projects",
74-
related_query_name="projectspecifier",
75-
on_delete=models.CASCADE)
83+
remote = models.ForeignKey(
84+
"PythonRemote",
85+
related_name="projects",
86+
related_query_name="projectspecifier",
87+
on_delete=models.CASCADE
88+
)
7689

7790

7891
class PythonPackageContent(Content):
7992
"""
80-
A Content Type representing Python's Distribution Package as
81-
defined in pep-0426 and pep-0345
93+
A Content Type representing Python's Distribution Package.
94+
95+
As defined in pep-0426 and pep-0345.
96+
8297
https://www.python.org/dev/peps/pep-0491/
8398
https://www.python.org/dev/peps/pep-0345/
8499
"""
@@ -112,20 +127,30 @@ class PythonPackageContent(Content):
112127

113128
@property
114129
def artifact(self):
130+
"""
131+
Return the artifact id (there is only one for this content type).
132+
"""
115133
return self.artifacts.get().pk
116134

117135
class Meta:
118-
unique_together = (
119-
'filename',
120-
)
136+
unique_together = ('filename',)
121137

122138
def __str__(self):
123139
"""
124-
Overrides Content.str to provide the distribution version and type at the end.
140+
Provide more useful repr information.
141+
142+
Overrides Content.str to provide the distribution version and type at
143+
the end.
144+
125145
e.g. <PythonPackageContent: shelf-reader [version] (whl)>
146+
126147
"""
127-
return '<{}: {} [{}] ({})>'.format(
128-
self._meta.object_name, self.name, self.version, self.packagetype)
148+
return '<{obj_name}: {name} [{version}] ({type})>'.format(
149+
obj_name=self._meta.object_name,
150+
name=self.name,
151+
version=self.version,
152+
type=self.packagetype
153+
)
129154

130155

131156
class PythonPublisher(Publisher):
@@ -139,9 +164,6 @@ class PythonPublisher(Publisher):
139164
class PythonRemote(Remote):
140165
"""
141166
A Remote for Python Content.
142-
143-
Attributes:
144-
projects (list): A list of python projects to sync
145167
"""
146168

147169
TYPE = 'python'

pulp_python/app/serializers.py

+25-28
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class ClassifierSerializer(serializers.ModelSerializer):
1414
"""
15-
A serializer for Python Classifiers
15+
A serializer for Python Classifiers.
1616
"""
1717

1818
name = serializers.CharField(
@@ -26,12 +26,12 @@ class Meta:
2626

2727
class DistributionDigestSerializer(serializers.ModelSerializer):
2828
"""
29-
A serializer for the Distribution Digest in a Project Specifier
29+
A serializer for the Distribution Digest in a Project Specifier.
3030
"""
31+
3132
type = serializers.CharField(
3233
help_text=_("A type of digest: i.e. sha256, md5")
3334
)
34-
3535
digest = serializers.CharField(
3636
help_text=_("The digest of the distribution")
3737
)
@@ -43,32 +43,30 @@ class Meta:
4343

4444
class ProjectSpecifierSerializer(serializers.ModelSerializer):
4545
"""
46-
A serializer for Python project specifiers
46+
A serializer for Python project specifiers.
4747
"""
4848

4949
name = serializers.CharField(
5050
help_text=_("A python project name.")
5151
)
52-
5352
version_specifier = serializers.CharField(
54-
help_text=_("A version specifier, accepts standard python versions "
55-
"syntax: >=, <=, ==, ~=, >, <, ! can be used in conjunction with"
56-
"other specifiers i.e. >1,<=3,!=3.0.2. Note that the specifiers "
57-
"treat pre-released versions as < released versions, so 3.0.0a1 < 3.0.0."
58-
"Not setting the version_specifier will sync all the pre-released and"
59-
"released versions."),
53+
help_text=_(
54+
"A version specifier, accepts standard python versions syntax:"
55+
" >=, <=, ==, ~=, >, <, ! can be used in conjunction with other specifiers i.e."
56+
" >1,<=3,!=3.0.2. Note that the specifiers treat pre-released versions as < released"
57+
" versions, so 3.0.0a1 < 3.0.0. Not setting the version_specifier will sync all the "
58+
"pre-released and released versions."),
6059
required=False,
6160
allow_blank=True
6261
)
63-
6462
digests = DistributionDigestSerializer(
6563
required=False,
6664
many=True
6765
)
6866

6967
def validate_version_specifier(self, value):
7068
"""
71-
Check that the Version Specifier is valid
69+
Check that the Version Specifier is valid.
7270
"""
7371
try:
7472
specifiers.SpecifierSet(value)
@@ -199,17 +197,17 @@ class PythonPackageContentSerializer(core_serializers.ContentSerializer):
199197

200198
def create(self, validated_data):
201199
"""
202-
Creates a PythonPackageContent
200+
Create a PythonPackageContent.
201+
203202
Overriding default create() to write the classifiers nested field
204203
205-
args:
206-
validated_data (dict): data used to create the PythonPackageContent
204+
Args:
205+
validated_data (dict): Data used to create the PythonPackageContent
207206
208-
returns:
209-
models.PythonPackageContent: the created PythonPackageContent
207+
Returns:
208+
models.PythonPackageContent: The created PythonPackageContent
210209
211210
"""
212-
213211
classifiers = validated_data.pop('classifiers')
214212
artifact = validated_data.pop('artifact')
215213

@@ -253,19 +251,18 @@ class Meta:
253251
@transaction.atomic
254252
def update(self, instance, validated_data):
255253
"""
256-
Updates a PythonRemote
254+
Update a PythonRemote.
255+
257256
Overriding default update() to write the projects nested field
258257
259-
args:
258+
Args:
260259
instance (models.PythonRemote): instance of the python remote to update
261260
validated_data (dict): of validated data to update
262-
partial (bool): True for partial update, False otherwise
263261
264-
returns:
262+
Returns:
265263
models.PythonRemote: the updated PythonRemote
266264
267265
"""
268-
269266
projects = validated_data.pop('projects', [])
270267

271268
python_remote = python_models.PythonRemote.objects.get(pk=instance.pk)
@@ -288,17 +285,17 @@ def update(self, instance, validated_data):
288285
@transaction.atomic
289286
def create(self, validated_data):
290287
"""
291-
Creates a PythonRemote
288+
Create a PythonRemote.
289+
292290
Overriding default create() to write the projects nested field, and the nested digest field
293291
294-
args:
292+
Args:
295293
validated_data (dict): data used to create the remote
296294
297-
returns:
295+
Returns:
298296
models.PythonRemote: the created PythonRemote
299297
300298
"""
301-
302299
projects = validated_data.pop('projects', [])
303300

304301
python_remote = python_models.PythonRemote.objects.create(**validated_data)

pulp_python/app/tasks/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
from .publish import publish # noqa
2-
from .sync import sync # noqa
1+
"""
2+
Asynchronous task definitions.
3+
"""
4+
5+
from .publish import publish # noqa:E722
6+
from .sync import sync # noqa:E722

0 commit comments

Comments
 (0)