@@ -2727,14 +2727,10 @@ def with_resources_count(self):
27272727 return self .annotate (resources_count = count_subquery )
27282728
27292729 def has_license_detections (self ):
2730- return self .filter (
2731- ~ Q (license_detections = []) | ~ Q (other_license_detections = [])
2732- )
2730+ return self .filter (~ Q (license_detections = []) | ~ Q (other_license_detections = []))
27332731
27342732 def has_no_license_detections (self ):
2735- return self .filter (
2736- Q (license_detections = []) & Q (other_license_detections = [])
2737- )
2733+ return self .filter (Q (license_detections = []) & Q (other_license_detections = []))
27382734
27392735
27402736class AbstractPackage (models .Model ):
@@ -3504,39 +3500,39 @@ class AbstractLicenseDetection(models.Model):
35043500 license_expression = models .TextField (
35053501 blank = True ,
35063502 help_text = _ (
3507- ' A license expression string using the SPDX license expression'
3508- ' syntax and ScanCode license keys, the effective license expression'
3509- ' for this license detection.'
3503+ " A license expression string using the SPDX license expression"
3504+ " syntax and ScanCode license keys, the effective license expression"
3505+ " for this license detection."
35103506 ),
35113507 )
35123508
35133509 license_expression_spdx = models .TextField (
35143510 blank = True ,
3515- help_text = _ (' SPDX license expression string with SPDX ids.' ),
3511+ help_text = _ (" SPDX license expression string with SPDX ids." ),
35163512 )
35173513
35183514 matches = models .JSONField (
35193515 _ ("Reference Matches" ),
35203516 default = list ,
35213517 blank = True ,
3522- help_text = _ (' List of license matches combined in this detection.' ),
3518+ help_text = _ (" List of license matches combined in this detection." ),
35233519 )
35243520
35253521 detection_log = models .JSONField (
35263522 default = list ,
35273523 blank = True ,
35283524 help_text = _ (
3529- ' A list of detection DetectionRule explaining how '
3530- ' this detection was created.'
3525+ " A list of detection DetectionRule explaining how "
3526+ " this detection was created."
35313527 ),
35323528 )
35333529
35343530 identifier = models .CharField (
35353531 max_length = 1024 ,
35363532 blank = True ,
35373533 help_text = _ (
3538- ' An identifier unique for a license detection, containing the license '
3539- ' expression and a UUID crafted from the match contents.'
3534+ " An identifier unique for a license detection, containing the license "
3535+ " expression and a UUID crafted from the match contents."
35403536 ),
35413537 )
35423538
@@ -3552,10 +3548,11 @@ class DiscoveredLicense(
35523548 AbstractLicenseDetection ,
35533549):
35543550 """
3555- A project's Discovered Licenses are the unique License Detection objects
3551+ A project's Discovered Licenses are the unique License Detection objects
35563552 discovered in the code under analysis.
35573553
35583554 """
3555+
35593556 license_expression_field = "license_expression"
35603557
35613558 # If this license was discovered in a extracted license statement
@@ -3573,10 +3570,10 @@ class DiscoveredLicense(
35733570 default = list ,
35743571 blank = True ,
35753572 help_text = _ (
3576- ' A list of file regions with resource path, start and end line '
3577- ' details for each place this license detection was discovered at. '
3578- ' Also contains whether this license was discovered from a file or '
3579- ' from package metadata.'
3573+ " A list of file regions with resource path, start and end line "
3574+ " details for each place this license detection was discovered at. "
3575+ " Also contains whether this license was discovered from a file or "
3576+ " from package metadata."
35803577 ),
35813578 )
35823579
@@ -3604,9 +3601,10 @@ def __str__(self):
36043601 @classmethod
36053602 def create_from_data (cls , project , detection_data ):
36063603 """
3607- Create and returns a DiscoveredLicense for a `project` from the `detection_data`.
3608- If one of the values of the required fields is not available, a "ProjectMessage"
3609- is created instead of a new DiscoveredLicense instance.
3604+ Create and returns a DiscoveredLicense for a `project` from the
3605+ `detection_data`. If one of the values of the required fields is not
3606+ available, a "ProjectMessage" is created instead of a new
3607+ DiscoveredLicense instance.
36103608 """
36113609 detection_data = detection_data .copy ()
36123610 required_fields = ["license_expression" , "identifier" , "matches" ]
@@ -3622,7 +3620,11 @@ def create_from_data(cls, project, detection_data):
36223620 f"{ ', ' .join (missing_values )} "
36233621 )
36243622
3625- project .add_warning (description = message , model = cls , details = detection_data )
3623+ project .add_warning (
3624+ description = message ,
3625+ model = cls ,
3626+ details = detection_data ,
3627+ )
36263628 return
36273629
36283630 cleaned_data = {
@@ -3633,8 +3635,8 @@ def create_from_data(cls, project, detection_data):
36333635
36343636 discovered_license = cls (project = project , ** cleaned_data )
36353637 # Using save_error=False to not capture potential errors at this level but
3636- # rather in the CodebaseResource.create_and_add_license_data method so resource data
3637- # can be injected in the ProjectMessage record.
3638+ # rather in the CodebaseResource.create_and_add_license_data method so
3639+ # resource data can be injected in the ProjectMessage record.
36383640 discovered_license .save (save_error = False , capture_exception = False )
36393641 return discovered_license
36403642
@@ -3644,7 +3646,7 @@ def update_with_file_region(self, file_region):
36443646 `file_regions` list and increase the `detection_count` by 1.
36453647 """
36463648 file_region_data = file_region .to_dict ()
3647- if not file_region_data in self .file_regions :
3649+ if file_region_data not in self .file_regions :
36483650 self .file_regions .append (file_region_data )
36493651 if not self .detection_count :
36503652 self .detection_count = 1
0 commit comments