__init__.py 511 B

1234567891011121314151617
  1. import os
  2. def get_ruff_config(path, config_paths, arc_root):
  3. # type(str, dict, str) -> Optional[str]
  4. relative_path = os.path.relpath(path, arc_root)
  5. # find longest path
  6. deepest_path = ''
  7. for p in config_paths.keys():
  8. if relative_path.startswith(p) and len(p) > len(deepest_path):
  9. deepest_path = p
  10. if deepest_path:
  11. config = config_paths[deepest_path]
  12. full_config_path = os.path.join(arc_root, config)
  13. return full_config_path
  14. return None