-
Notifications
You must be signed in to change notification settings - Fork 45
UTBot Python updates from SBFT version #2725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
utbot-cli-python/src/README.md
Outdated
@@ -6,25 +6,25 @@ | |||
|
|||
- Required Java version: 11. | |||
|
|||
- Prefered Python version: 3.8+. | |||
- Preferred Python version: 3.11+. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably do not support Python 3.12: there were changes in syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated comment
def coverage(self, filename: str) -> typing.List[int]: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This try - except
is weird. Maybe it should be changed to explicit isinstance
or None
checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Description
Refactoring and new features form SBFT branch:
@staticmethod
decoratortyping.Any
annotationsHow to test
Automated tests
Run
utbot-python/samples/run_all_tests.sh
and checkCOVERAGE_REPORT
Self-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.