Skip to content

Conversation

tamarinvs19
Copy link
Collaborator

Description

Refactoring and new features form SBFT branch:

  • prepared structure to use symbolic execution
  • supported iterators in fuzzing and codegen
  • supported @staticmethod decorator
  • refactored cli interface: arguments, cancellation, parsing
  • new timeout separation between testing elements
  • improved type inference and generic substitutions
  • improved fuzzing for typing.Any annotations

How to test

Automated tests

Run utbot-python/samples/run_all_tests.sh and check COVERAGE_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.

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@tamarinvs19 tamarinvs19 added ctg-enhancement New feature, improvement or change request comp-codegen Issue is related to code generator ctg-refactoring Issue related to refactoring process comp-fuzzing Issue is related to the fuzzing comp-cli Issue related to CLI lang-python Issue is related to python support labels Dec 19, 2023
@tamarinvs19 tamarinvs19 self-assigned this Dec 19, 2023
@@ -6,25 +6,25 @@

- Required Java version: 11.

- Prefered Python version: 3.8+.
- Preferred Python version: 3.11+.
Copy link
Member

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.

Copy link
Collaborator Author

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):
Copy link
Member

@tochilinak tochilinak Dec 20, 2023

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) {
Copy link
Member

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.

Copy link
Collaborator Author

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

Copy link
Member

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:
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@tamarinvs19 tamarinvs19 enabled auto-merge (squash) December 21, 2023 12:26
@tamarinvs19 tamarinvs19 disabled auto-merge December 21, 2023 12:26
@tamarinvs19 tamarinvs19 merged commit c7f2ac4 into main Dec 22, 2023
@tamarinvs19 tamarinvs19 deleted the tamarinvs19/python-big-update branch December 22, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-cli Issue related to CLI comp-codegen Issue is related to code generator comp-fuzzing Issue is related to the fuzzing ctg-enhancement New feature, improvement or change request ctg-refactoring Issue related to refactoring process lang-python Issue is related to python support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants