title: How do I type hint a filename in a function?
body: <p>What is a best way in Python to hint a filename,
  so that it's acceptable to pass anything into a function that you can open as a file?</p>
  
  <p>Especially both strings and files found via Pathlib.</p>
  
  <pre><code>def myfunc(filename: str) -&gt; None:
      with open(filename) as f1:
          # do something here
  </code></pre>