title: TypeError: filter must be an instance of dict, bson.son.SON, or any other type that inherits from collections.Mapping
body: <p>In a Python function If I write like this, I get <em>Expected expression Pylance</em> in vscode.</p>
  <pre><code>    document = await collection.find({'date': {$gte: {start_date}, $lte: {end_date}}}).to_list(100)
  </code></pre>
  <p>Here, <code>date</code> is my <em>field</em> and <code>sart_date</code>, <code>end_date</code> are the dynamic value that specify the specific range of documents I'd like to get from database.</p>
  <p>And, then because of Pylance error, I changed code like this:</p>
  <pre><code>    query_string = {&quot;date&quot;: f'{{date: {{$gte: {start_date}, $lte: {end_date}}}}}'}
  
      document = await collection.find(query_string[&quot;date&quot;]).to_list(100)
  </code></pre>
  <p>And also, writing <code>print(query_string)</code> I get <strong>{date: {$gte: '2021-07-15T16:18:46.688Z', $lte: '2021-07-18T12:18:45.258Z'}}</strong> on terminal as well that means the value of <em>query_string</em> variable is right. Even If I check with this query in mongodb compass gui app, it returns me the desired data from database. So why getting title's error when the function runs? Please, help me up.</p>
  <blockquote>
  <p>For your convenience, the whole function is:</p>
  </blockquote>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code># routing in FastAPI
  @router.get('/api/{start_date}_{end_date}') 
  async def query_date_from_person(start_date, end_date):
      query_string = {"date": f'{{date: {{$gte: {start_date}, $lte: {end_date}}}}}'}
      document = await collection.find(query_string["date"]).to_list(100)
      return document</code></pre>
  </div>
  </div>
  </p>