Code Duplication not detected

Template for a good bug report, formatted with Markdown:

  • SonarQube Version used: 8.9 LTS Enterprise Edition. Scanner Version used: 4.6.2.2472

I have an example where I observe a strange behaviour on code duplications:
Assume, this is the content of a Python file:

class ClassA():
    config_dict = {}
    source_type = None

    def doSomething(self, config_dict, source_type):
        try:
            self.logger.warning("doNothing")

        except WorkflowException as err:
            self.logger.warning("Any warning message to print {} and {}".format(source_type, err.message))
            if Constants.MY_CONSTANT:
                self.logger.error("Error Message")
                UtilityClass.cleanup(config_dict[ConfigurationDict.TARGET_DIR], config_dict[ConfigurationDict.BUILD_PLATFORM])
                ReportClass.write_json_file(self.config_parser, self.traceability_report, None)
                sys.exit(1)
            else:
                self.logger.warning(
                    "Warning message: {}"
                    .format(source_type))
                if source_type == ConfigurationDict.C:
                    self.config_parser.is_c_executable = False
                if source_type == ConfigurationDict.CPP:
                    self.config_parser.is_cpp_executable = False

class ClassB():
    config_dict = {}
    source_type = None

    def doSomething(self, config_dict, source_type):
        try:
            self.logger.warning("doNothing")

        except WorkflowException as err:
            self.logger.warning("Any warning message to print {} and {}".format(source_type, err.message))
            if Constants.MY_CONSTANT:
                self.logger.error("Error Message")
                UtilityClass.cleanup(config_dict[ConfigurationDict.TARGET_DIR], config_dict[ConfigurationDict.BUILD_PLATFORM])
                ReportClass.write_json_file(self.config_parser, self.traceability_report, None)
                sys.exit(1)
            else:
                self.logger.warning(
                    "Warning message: {}"
                    .format(source_type))
                if source_type == ConfigurationDict.C:
                    self.config_parser.is_c_executable = False
                if source_type == ConfigurationDict.CPP:
                    self.config_parser.is_cpp_executable = False
        finally:
            WorkflowAnalysisUtil.retry_count = 0

As you can see, there are two different classes, but having the same function with almost the same content (for ClassB, there is an additional finally block which does not exist in ClassA).
When running analysis using scanner, for sure, this code duplication will be detected.

But when changing line self.logger.warning("Any warning message to print {} and {}".format(source_type, err.message)) to self.logger.warning("Foo {} and {}".format(source_type, err.message)) in function doSomething() of ClassA, the code duplication is not reported anymore!

Note: Also applying

sonar.cpd.python.minimumtokens=1
sonar.cpd.python.minimumLines=1
sonar.cpd.cross_project=true

in properties file does not have any effect!

Any help is welcome!

Thank you in advance!