Advanced type inference for Python