Is it possible to open and read cythonized .so
files with python?
The use-case is a test that scans all python files in a directory and evaluates if certain object attributes are used (to be ultimately able to identify and remove unused attributes).
This test runs perfectly on the local environment but in our CI that cythonizes all files this breaks, as .so
files can't be parsed.
Currently I am scanning the files for the object attribute occurrences like this:
import os
path = '/path/to/dir'
attribute_regex = r'object\.(\w+)'
used_attributes = set()
for root, _, files in os.walk(path):
for file in files:
with open(os.path.join(root, file), 'r') as f:
used_attributes.update(re.findall(attribute_regex, f))
Maybe I am looking at this issue from the wrong angle, are there other more sophisticated ways to check if attributes of an object are used across multiple python files?