Let's say there is an open source project published with a very permissive license that has one function you need. Putting the whole project as a dependency is an overkill and rewriting the function with your own variable names and indentation doesn't sound like an improvement.
Would adding a copyright notice somewhere in the repository be enough?