Hacker News new | past | comments | ask | show | jobs | submit login

Interesting refactor!

This is trivial with codegen.com. Syntax below:

  # Iterate through all files in the codebase
  for file in codebase.files:
      # Check for functions with the pytest.fixture decorator
      for function in file.functions:
          if any(d.name == "fixture" for d in function.decorators):
              # Rename the 'db' parameter to 'database'
              db_param = function.get_parameter("db")
              if db_param:
                  db_param.set_name("database")
                  # Log the modification
                  print(f"Modified {function.name}")
Live example: https://www.codegen.sh/codemod/4697/public/diff



Consider indenting your code block, it's unreadable as it is now.


Good call, thank you


That's pretty sick. Super readable with python :)

Is each file getting parsed individually with tree-sitter or how is the codebase object constructed?


We do advanced static analysis to provide programmatic access to the type system, etc., based on tree-sitter and in-house tech.

This enables APIs such as `function.call_sites`, `symbol.usages`, `class.parent_classes`, and more!


Where can I learn more about this? You guys don't seem to have any docs available.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: