Skip to content

Commit aa37e56

Browse files
authored
Merge pull request #182 from CycloneDX/sort-imports
style: sort imports
2 parents a3ed3c7 + 4780a84 commit aa37e56

30 files changed

+322
-69
lines changed

.isort.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[settings]
2+
## read the docs: https://pycqa.github.io/isort/docs/configuration/options.html
3+
## keep in sync with flake8 config - in `tox.ini` file
4+
known_first_party = cyclonedx
5+
skip_gitignore = true
6+
skip_glob =
7+
build/*,dist/*,__pycache__,.eggs,*.egg-info*,
8+
*_cache,*.cache,
9+
.git/*,.tox/*,.venv/*,venv/*
10+
_OLD/*,_TEST/*,
11+
docs/*
12+
combine_as_imports = true
13+
default_section = THIRDPARTY
14+
ensure_newline_before_comments = true
15+
include_trailing_comma = true
16+
line_length = 120
17+
multi_line_output = 3

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ poetry install
1818
## Code style
1919

2020
This project uses [PEP8] Style Guide for Python Code.
21-
Get it applied via:
21+
This project loves sorted imports.
22+
Get it all applied via:
2223

2324
```shell
25+
poetry run isort .
2426
poetry run autopep8 --in-place -r .
2527
```
2628

2729
## Testing
2830

31+
Run all tests in dedicated environments, via:
32+
2933
```shell
3034
poetry run tox
3135
```

cyclonedx/model/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
1718
import hashlib
1819
import re
1920
import sys
@@ -22,8 +23,13 @@
2223
from enum import Enum
2324
from typing import Iterable, Optional, Set
2425

25-
from ..exception.model import InvalidLocaleTypeException, InvalidUriException, NoPropertiesProvidedException, \
26-
MutuallyExclusivePropertiesException, UnknownHashTypeException
26+
from ..exception.model import (
27+
InvalidLocaleTypeException,
28+
InvalidUriException,
29+
MutuallyExclusivePropertiesException,
30+
NoPropertiesProvidedException,
31+
UnknownHashTypeException,
32+
)
2733

2834
"""
2935
Uniform set of models to represent objects within a CycloneDX software bill-of-materials.

cyclonedx/model/bom.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
#
1717
# SPDX-License-Identifier: Apache-2.0
1818
# Copyright (c) OWASP Foundation. All Rights Reserved.
19+
1920
from datetime import datetime, timezone
2021
from typing import Iterable, Optional, Set
21-
from uuid import uuid4, UUID
22+
from uuid import UUID, uuid4
2223

23-
from . import ExternalReference, OrganizationalContact, OrganizationalEntity, LicenseChoice, Property, ThisTool, Tool
24+
from ..parser import BaseParser
25+
from . import ExternalReference, LicenseChoice, OrganizationalContact, OrganizationalEntity, Property, ThisTool, Tool
2426
from .component import Component
2527
from .service import Service
26-
from ..parser import BaseParser
2728

2829

2930
class BomMetaData:

cyclonedx/model/bom_ref.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717
# SPDX-License-Identifier: Apache-2.0
1818
# Copyright (c) OWASP Foundation. All Rights Reserved.
19+
1920
from typing import Optional
2021
from uuid import uuid4
2122

cyclonedx/model/component.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717
# SPDX-License-Identifier: Apache-2.0
1818
# Copyright (c) OWASP Foundation. All Rights Reserved.
19+
1920
import warnings
2021
from enum import Enum
2122
from os.path import exists
@@ -24,13 +25,24 @@
2425
# See https://github.com/package-url/packageurl-python/issues/65
2526
from packageurl import PackageURL # type: ignore
2627

27-
from . import AttachedText, Copyright, ExternalReference, HashAlgorithm, HashType, IdentifiableAction, LicenseChoice, \
28-
OrganizationalEntity, Property, sha1sum, XsUri
28+
from ..exception.model import NoPropertiesProvidedException
29+
from . import (
30+
AttachedText,
31+
Copyright,
32+
ExternalReference,
33+
HashAlgorithm,
34+
HashType,
35+
IdentifiableAction,
36+
LicenseChoice,
37+
OrganizationalEntity,
38+
Property,
39+
XsUri,
40+
sha1sum,
41+
)
2942
from .bom_ref import BomRef
3043
from .issue import IssueType
3144
from .release_note import ReleaseNotes
3245
from .vulnerability import Vulnerability
33-
from ..exception.model import NoPropertiesProvidedException
3446

3547

3648
class Commit:

cyclonedx/model/issue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
1718
from enum import Enum
1819
from typing import Iterable, Optional, Set
1920

20-
from . import XsUri
2121
from ..exception.model import NoPropertiesProvidedException
22+
from . import XsUri
2223

2324

2425
class IssueClassification(Enum):

cyclonedx/model/release_note.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717
# SPDX-License-Identifier: Apache-2.0
1818
# Copyright (c) OWASP Foundation. All Rights Reserved.
19+
1920
from datetime import datetime
2021
from typing import Iterable, Optional, Set
2122

cyclonedx/model/service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
1718
from typing import Iterable, Optional, Set
1819

19-
from . import ExternalReference, DataClassification, LicenseChoice, OrganizationalEntity, Property, XsUri
20+
from . import DataClassification, ExternalReference, LicenseChoice, OrganizationalEntity, Property, XsUri
2021
from .bom_ref import BomRef
2122
from .release_note import ReleaseNotes
2223

cyclonedx/model/vulnerability.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,23 @@
1616
#
1717
# SPDX-License-Identifier: Apache-2.0
1818
# Copyright (c) OWASP Foundation. All Rights Reserved.
19+
1920
import re
2021
import warnings
2122
from datetime import datetime
2223
from decimal import Decimal
2324
from enum import Enum
2425
from typing import Iterable, Optional, Set, Tuple, Union
2526

27+
from ..exception.model import MutuallyExclusivePropertiesException, NoPropertiesProvidedException
2628
from . import OrganizationalContact, OrganizationalEntity, Tool, XsUri
2729
from .bom_ref import BomRef
28-
from .impact_analysis import ImpactAnalysisAffectedStatus, ImpactAnalysisJustification, ImpactAnalysisResponse, \
29-
ImpactAnalysisState
30-
from ..exception.model import MutuallyExclusivePropertiesException, NoPropertiesProvidedException
30+
from .impact_analysis import (
31+
ImpactAnalysisAffectedStatus,
32+
ImpactAnalysisJustification,
33+
ImpactAnalysisResponse,
34+
ImpactAnalysisState,
35+
)
3136

3237
"""
3338
This set of classes represents the data that is possible about known Vulnerabilities.

0 commit comments

Comments
 (0)