Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.10
    • Component/s: Rules
    • Labels:
      None

      Description

      Rule RSPEC-1192 should ignore type hints when they are passed as strings. Type checkers will raise an issue if the type hint has a typo, and putting these strings in a variable doesn't help readability.

      Example:

      import httpx
      import asyncio
      
      async def func():
          asyncwith httpx.AsyncClient() as client:
              r1: 'httpx.Response' = await client.get('[https://www.example1.org/')]  # False Positive on 'httpx.Response'
              r2: 'httpx.Response' = await client.get('https://www.example2.org/')
              r3: 'httpx.Response' = await client.get('https://www.example3.org/')
              print(r1.status_code, r2.status_code, r3.status_code)
      
      asyncio.run(func())
      

      See PEP 484 Forward references:

      When a type hint contains names that have not been defined yet, that definition may be expressed as a string literal, to be resolved later.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                andrea.guarino Andrea Guarino
                Reporter:
                nicolas.harraudeau Nicolas Harraudeau
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: