UTBot Python updates from SBFT version#2725
Conversation
| - Required Java version: 11. | ||
|
|
||
| - Prefered Python version: 3.8+. | ||
| - Preferred Python version: 3.11+. |
There was a problem hiding this comment.
We probably do not support Python 3.12: there were changes in syntax.
There was a problem hiding this comment.
Updated comment
| filename = _modname(filename) | ||
| return [line for file, line in self.counts.keys() if file == filename] | ||
|
|
||
| def localtrace_count(self, frame, why, arg): |
There was a problem hiding this comment.
Note for the future: I think we should measure how slow is our tracing and find ways to accelerate it. Right now I can think of one approach to do this: use native tracing (https://docs.python.org/3/c-api/init.html?highlight=settrace#c.PyEval_SetTrace).
Or maybe try out mypy's script for turning Python scripts into C extensions (https://github.com/python/mypy?tab=readme-ov-file#mypyc-and-compiled-version-of-mypy). Mypy itself is several times faster with compiled version (checked that myself).
Maybe there are easier ways to do that.
| .map { DefaultSubstitutionProvider.substitute(it, substitution) }, | ||
| DefaultSubstitutionProvider.substitute(functionType.returnValue, substitution) | ||
| ) | ||
| } catch (_: ClassCastException) { |
There was a problem hiding this comment.
If there is a case when this exception happens, this is a bug in utbot-python-types module.
There was a problem hiding this comment.
Removed catch. As far as I remember, this exception was only actual for decorated methods except for @staticmethod but now we don't support them
There was a problem hiding this comment.
I think I figured out the situation when this might happen:
class A(Generic[T]):
def f(self, a: T): ...If you want to substitute only parameters that are bounded to the function, use getBoundedParameters (https://github.com/UnitTestBot/UTBotJava/blob/main/utbot-python-types/src/main/kotlin/org/utbot/python/newtyping/general/TypeUtils.kt#L15)
| if isinstance(defn, mypy.nodes.ClassDef): | ||
| for inner_class in filter(lambda x: isinstance(x, mypy.nodes.ClassDef), table_node.node.defn.defs.body): | ||
| definitions[f"{base_name}.{inner_class.name}"] = get_definition_from_node(inner_class.info, meta, only_types) | ||
| except AttributeError: |
There was a problem hiding this comment.
This try - except is weird. Maybe it should be changed to explicit isinstance or None checks?
Description
Refactoring and new features form SBFT branch:
@staticmethoddecoratortyping.AnyannotationsHow to test
Automated tests
Run
utbot-python/samples/run_all_tests.shand checkCOVERAGE_REPORTSelf-check list
Check off the item if the statement is true. Hint: [x] is a marked item.
Please do not delete the list or its items.