@@ -2685,14 +2685,10 @@ def with_resources_count(self):
26852685 return self .annotate (resources_count = count_subquery )
26862686
26872687 def has_license_detections (self ):
2688- return self .filter (
2689- ~ Q (license_detections = []) | ~ Q (other_license_detections = [])
2690- )
2688+ return self .filter (~ Q (license_detections = []) | ~ Q (other_license_detections = []))
26912689
26922690 def has_no_license_detections (self ):
2693- return self .filter (
2694- Q (license_detections = []) & Q (other_license_detections = [])
2695- )
2691+ return self .filter (Q (license_detections = []) & Q (other_license_detections = []))
26962692
26972693
26982694class AbstractPackage (models .Model ):
@@ -3454,39 +3450,39 @@ class AbstractLicenseDetection(models.Model):
34543450 license_expression = models .TextField (
34553451 blank = True ,
34563452 help_text = _ (
3457- ' A license expression string using the SPDX license expression'
3458- ' syntax and ScanCode license keys, the effective license expression'
3459- ' for this license detection.'
3453+ " A license expression string using the SPDX license expression"
3454+ " syntax and ScanCode license keys, the effective license expression"
3455+ " for this license detection."
34603456 ),
34613457 )
34623458
34633459 license_expression_spdx = models .TextField (
34643460 blank = True ,
3465- help_text = _ (' SPDX license expression string with SPDX ids.' ),
3461+ help_text = _ (" SPDX license expression string with SPDX ids." ),
34663462 )
34673463
34683464 matches = models .JSONField (
34693465 _ ("Reference Matches" ),
34703466 default = list ,
34713467 blank = True ,
3472- help_text = _ (' List of license matches combined in this detection.' ),
3468+ help_text = _ (" List of license matches combined in this detection." ),
34733469 )
34743470
34753471 detection_log = models .JSONField (
34763472 default = list ,
34773473 blank = True ,
34783474 help_text = _ (
3479- ' A list of detection DetectionRule explaining how '
3480- ' this detection was created.'
3475+ " A list of detection DetectionRule explaining how "
3476+ " this detection was created."
34813477 ),
34823478 )
34833479
34843480 identifier = models .CharField (
34853481 max_length = 1024 ,
34863482 blank = True ,
34873483 help_text = _ (
3488- ' An identifier unique for a license detection, containing the license '
3489- ' expression and a UUID crafted from the match contents.'
3484+ " An identifier unique for a license detection, containing the license "
3485+ " expression and a UUID crafted from the match contents."
34903486 ),
34913487 )
34923488
@@ -3502,10 +3498,11 @@ class DiscoveredLicense(
35023498 AbstractLicenseDetection ,
35033499):
35043500 """
3505- A project's Discovered Licenses are the unique License Detection objects
3501+ A project's Discovered Licenses are the unique License Detection objects
35063502 discovered in the code under analysis.
35073503
35083504 """
3505+
35093506 license_expression_field = "license_expression"
35103507
35113508 # If this license was discovered in a extracted license statement
@@ -3523,10 +3520,10 @@ class DiscoveredLicense(
35233520 default = list ,
35243521 blank = True ,
35253522 help_text = _ (
3526- ' A list of file regions with resource path, start and end line '
3527- ' details for each place this license detection was discovered at. '
3528- ' Also contains whether this license was discovered from a file or '
3529- ' from package metadata.'
3523+ " A list of file regions with resource path, start and end line "
3524+ " details for each place this license detection was discovered at. "
3525+ " Also contains whether this license was discovered from a file or "
3526+ " from package metadata."
35303527 ),
35313528 )
35323529
@@ -3554,9 +3551,10 @@ def __str__(self):
35543551 @classmethod
35553552 def create_from_data (cls , project , detection_data ):
35563553 """
3557- Create and returns a DiscoveredLicense for a `project` from the `detection_data`.
3558- If one of the values of the required fields is not available, a "ProjectMessage"
3559- is created instead of a new DiscoveredLicense instance.
3554+ Create and returns a DiscoveredLicense for a `project` from the
3555+ `detection_data`. If one of the values of the required fields is not
3556+ available, a "ProjectMessage" is created instead of a new
3557+ DiscoveredLicense instance.
35603558 """
35613559 detection_data = detection_data .copy ()
35623560 required_fields = ["license_expression" , "identifier" , "matches" ]
@@ -3572,7 +3570,11 @@ def create_from_data(cls, project, detection_data):
35723570 f"{ ', ' .join (missing_values )} "
35733571 )
35743572
3575- project .add_warning (description = message , model = cls , details = detection_data )
3573+ project .add_warning (
3574+ description = message ,
3575+ model = cls ,
3576+ details = detection_data ,
3577+ )
35763578 return
35773579
35783580 cleaned_data = {
@@ -3583,8 +3585,8 @@ def create_from_data(cls, project, detection_data):
35833585
35843586 discovered_license = cls (project = project , ** cleaned_data )
35853587 # Using save_error=False to not capture potential errors at this level but
3586- # rather in the CodebaseResource.create_and_add_license_data method so resource data
3587- # can be injected in the ProjectMessage record.
3588+ # rather in the CodebaseResource.create_and_add_license_data method so
3589+ # resource data can be injected in the ProjectMessage record.
35883590 discovered_license .save (save_error = False , capture_exception = False )
35893591 return discovered_license
35903592
@@ -3594,7 +3596,7 @@ def update_with_file_region(self, file_region):
35943596 `file_regions` list and increase the `detection_count` by 1.
35953597 """
35963598 file_region_data = file_region .to_dict ()
3597- if not file_region_data in self .file_regions :
3599+ if file_region_data not in self .file_regions :
35983600 self .file_regions .append (file_region_data )
35993601 if not self .detection_count :
36003602 self .detection_count = 1
0 commit comments