Skip to content

Commit cce6b9c

Browse files
committed
Improve and update code style
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 666aa03 commit cce6b9c

32 files changed

Lines changed: 255 additions & 234 deletions

docs/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"sphinx_rtd_dark_mode",
3535
"sphinx.ext.extlinks",
3636
"sphinx_copybutton",
37-
37+
]
3838
# Ensure there are no invalid URLs
3939
# Use -b linkcheck to check integrity of all external links
4040
nitpicky = True
@@ -77,3 +77,4 @@
7777
]
7878

7979
master_doc = "index"
80+

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ select = [
124124
"I", # isort
125125
# "C9", # McCabe complexity
126126
]
127-
ignore = ["D1", "D200", "D202", "D203", "D205", "D212", "D400", "D415", "I001"]
127+
ignore = ["D1", "D200", "D202", "D203", "D205", "D212", "D400", "D415", "I001",
128+
"D413", "D417"]
128129

129130

130131
[tool.ruff.lint.isort]

requirements-dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
doc8==1.1.2
2+
pytest==7.1.1
3+
pytest-django==4.5.2

requirements.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
aboutcode.pipeline==0.1.0
1+
aboutcode.pipeline==0.2.1
22
aiosignal==1.2.0
33
alabaster==0.7.12
44
asgiref==3.8.1
@@ -10,7 +10,6 @@ backcall==0.2.0
1010
bcrypt==3.2.0
1111
beautifulsoup4==4.10.0
1212
binaryornot==0.4.4
13-
black==22.3.0
1413
bleach==6.1.0
1514
boolean.py==4.0
1615
certifi==2024.7.4
@@ -34,7 +33,6 @@ django-filter==24.3
3433
django-recaptcha==4.0.0
3534
django-widget-tweaks==1.5.0
3635
djangorestframework==3.15.2
37-
doc8==0.11.1
3836
docopt==0.6.2
3937
docutils==0.17.1
4038
drf-spectacular==0.24.2
@@ -51,7 +49,6 @@ imagesize==1.3.0
5149
importlib-metadata==4.11.3
5250
iniconfig==1.1.1
5351
ipython==8.10.0
54-
isort==5.10.1
5552
itypes==1.2.0
5653
jedi==0.18.1
5754
Jinja2==3.1.6
@@ -80,7 +77,6 @@ psycopg2-binary==2.9.3
8077
ptyprocess==0.7.0
8178
pure-eval==0.2.2
8279
py==1.11.0
83-
pycodestyle==2.8.0
8480
pycparser==2.21
8581
Pygments==2.15.0
8682
PyNaCl==1.5.0
@@ -100,7 +96,7 @@ six==1.16.0
10096
smmap==5.0.0
10197
snowballstemmer==2.2.0
10298
soupsieve==2.3.2
103-
Sphinx==4.5.0
99+
Sphinx==5.02
104100
sphinxcontrib-applehelp==1.0.2
105101
sphinx-autobuild==2024.10.3
106102
sphinxcontrib-devhelp==1.0.2
@@ -110,7 +106,6 @@ sphinxcontrib-jsmath==1.0.1
110106
sphinxcontrib-qthelp==1.0.3
111107
sphinxcontrib-serializinghtml==1.1.5
112108
sphinx-rtd-theme==1.0.0
113-
sqlparse==0.5.0
114109
stack-data==0.2.0
115110
stevedore==3.5.0
116111
texttable==1.6.4

src/README.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/README.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

vulnerabilities/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class VulnerabilitySeverityAdmin(admin.ModelAdmin):
4141

4242
class ApiUserCreationForm(forms.ModelForm):
4343
"""
44-
This helps have a simplified creation for API-only users in the admin
44+
ApiUserCreationForm forms help the simplified creation of API-only users in the admin
4545
"""
4646

4747
class Meta:

vulnerabilities/importer.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,10 @@ def from_dict(cls, affected_pkg: dict):
288288
@dataclasses.dataclass(order=True)
289289
class AdvisoryData:
290290
"""
291-
This data class expresses the contract between data sources and the import runner.
291+
AdvisoryData data class expresses the contract between data sources and the import runner.
292292
293293
If a vulnerability_id is present then:
294+
294295
summary or affected_packages or references must be present
295296
otherwise
296297
either affected_package or references should be present
@@ -427,16 +428,15 @@ class OvalImporter(Importer):
427428
@staticmethod
428429
def create_purl(pkg_name: str, pkg_data: Mapping) -> PackageURL:
429430
"""
430-
Helper method for creating different purls for subclasses without them reimplementing
431-
get_data_from_xml_doc method
432-
Note: pkg_data must include 'type' of package
431+
Return a purl. Helper method for creating different purls for subclasses without them
432+
reimplementing get_data_from_xml_doc method Note: pkg_data must include 'type' of package
433433
"""
434434
return PackageURL(name=pkg_name, **pkg_data)
435435

436436
@staticmethod
437437
def _collect_pkgs(parsed_oval_data: Mapping) -> Set:
438438
"""
439-
Helper method, used for loading the API. It expects data from
439+
Collect packages. Helper method, used for loading the API. It expects data from
440440
OvalParser.get_data().
441441
"""
442442
all_pkgs = set()
@@ -477,14 +477,16 @@ def get_data_from_xml_doc(
477477
self, xml_doc: ET.ElementTree, pkg_metadata={}
478478
) -> Iterable[AdvisoryData]:
479479
"""
480+
Return an ietarble of AdvisoryData.
480481
The orchestration method of the OvalDataSource. This method breaks an
481482
OVAL xml ElementTree into a list of `Advisory`.
482483
483484
Note: pkg_metadata is a mapping of Package URL data that MUST INCLUDE
484485
"type" key.
485486
486487
Example value of pkg_metadata:
487-
{"type":"deb","qualifiers":{"distro":"buster"} }
488+
489+
{"type":"deb","qualifiers":{"distro":"buster"} }
488490
"""
489491
oval_parsed_data = OvalParser(self.translations, xml_doc)
490492
raw_data = oval_parsed_data.get_data()

vulnerabilities/importers/apache_httpd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def get_weaknesses(cve_data):
167167
Args:
168168
cve_data (dict): The CVE data in a dictionary format.
169169
170-
Returns:
170+
Return:
171171
List[int]: A list of unique CWE IDs.
172172
173173
Examples:

vulnerabilities/importers/curl.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def parse_advisory_data(raw_data) -> AdvisoryData:
6262
Args:
6363
raw_data (dict): Raw JSON data containing advisory information.
6464
65-
Returns:
65+
Return:
6666
AdvisoryData: Parsed advisory data as an AdvisoryData object.
6767
6868
Example:
@@ -148,12 +148,12 @@ def parse_advisory_data(raw_data) -> AdvisoryData:
148148

149149
def get_cwe_from_curl_advisory(raw_data):
150150
"""
151-
Extracts CWE IDs from the given raw_data and returns a list of CWE IDs.
151+
Extract CWE IDs from the given raw_data and returns a list of CWE IDs.
152152
153-
>>> get_cwe_from_curl_advisory({"database_specific": {"CWE": {"id": "CWE-333"}}})
154-
[333]
155-
>>> get_cwe_from_curl_advisory({"database_specific": {"CWE": {"id": ""}}})
156-
[]
153+
>>> get_cwe_from_curl_advisory({"database_specific": {"CWE": {"id": "CWE-333"}}})
154+
[333]
155+
>>> get_cwe_from_curl_advisory({"database_specific": {"CWE": {"id": ""}}})
156+
[]
157157
"""
158158
weaknesses = []
159159
db = Database()

0 commit comments

Comments
 (0)