- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.9k
 
          email.message: Fix invalid TypeVar usage; add some default values
          #9620
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | 
           Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip)
+ src/pip/_internal/metadata/_json.py:67: error: Item "None" of "Optional[List[Any]]" has no attribute "__iter__" (not iterable)  [union-attr]
+ src/pip/_internal/metadata/_json.py:70: error: Argument 1 to "sanitise_header" has incompatible type "Optional[Any]"; expected "Union[Header, str]"  [arg-type]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/helpers.py:749: error: Value of type "Optional[List[Tuple[str, str]]]" is not indexable  [index]
 | 
    
| 
           Links to the primer hits: These are both true positives, in my opinion: these are both cases where   | 
    
              
                    srittau
  
              
              approved these changes
              
                  
                    Jan 30, 2023 
                  
              
              
            
            
| 
           This would a good case for type var defaults (python/typing#307) as well.  | 
    
    
  bmwiedemann 
      pushed a commit
        to bmwiedemann/openSUSE
      that referenced
      this pull request
    
      Mar 21, 2023 
    
    
      
  
    
      
    
  
…2924 https://build.opensuse.org/request/show/1072924 by user dirkmueller + dimstar_suse - update to 6.1.0: * ``packages_distributions`` now honors packages and modules with Python modules that not ``.py`` sources (e.g. ``.pyc``, * ``.so``). * #434: Expand protocol for ``PackageMetadata.get_all`` to match the upstream implementation of ``email.message.Message.get_all`` in python/typeshed#9620.
    
  kraj 
      pushed a commit
        to YoeDistro/poky
      that referenced
      this pull request
    
      Apr 10, 2023 
    
    
      
  
    
      
    
  
Changelog: =========== - #384: PackageMetadata now stipulates an additional get method allowing for easy querying of metadata keys that may not be present. - #428: packages_distributions now honors packages and modules with Python modules that not .py sources (e.g. .pyc, .so). - #434: Expand protocol for PackageMetadata.get_all to match the upstream implementation of email.message.Message.get_all in python/typeshed#9620. (From OE-Core rev: 8cb0c21f597e4486229a7b42e00d3a681622ad9d) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    
  kraj 
      pushed a commit
        to YoeDistro/poky
      that referenced
      this pull request
    
      Apr 11, 2023 
    
    
      
  
    
      
    
  
Changelog: =========== - #384: PackageMetadata now stipulates an additional get method allowing for easy querying of metadata keys that may not be present. - #428: packages_distributions now honors packages and modules with Python modules that not .py sources (e.g. .pyc, .so). - #434: Expand protocol for PackageMetadata.get_all to match the upstream implementation of email.message.Message.get_all in python/typeshed#9620. (From OE-Core rev: 1aac50ba9b58866a91fb64c0408c4b0425ad1f75) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    
  kraj 
      pushed a commit
        to YoeDistro/poky
      that referenced
      this pull request
    
      Apr 11, 2023 
    
    
      
  
    
      
    
  
Changelog: =========== - #384: PackageMetadata now stipulates an additional get method allowing for easy querying of metadata keys that may not be present. - #428: packages_distributions now honors packages and modules with Python modules that not .py sources (e.g. .pyc, .so). - #434: Expand protocol for PackageMetadata.get_all to match the upstream implementation of email.message.Message.get_all in python/typeshed#9620. (From OE-Core rev: c718e376fa8453f1998416c3c22139711cd6ff56) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
    
  kraj 
      pushed a commit
        to YoeDistro/poky
      that referenced
      this pull request
    
      Apr 11, 2023 
    
    
      
  
    
      
    
  
Changelog: =========== - #384: PackageMetadata now stipulates an additional get method allowing for easy querying of metadata keys that may not be present. - #428: packages_distributions now honors packages and modules with Python modules that not .py sources (e.g. .pyc, .so). - #434: Expand protocol for PackageMetadata.get_all to match the upstream implementation of email.message.Message.get_all in python/typeshed#9620. (From OE-Core rev: c718e376fa8453f1998416c3c22139711cd6ff56) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
    
  kraj 
      pushed a commit
        to YoeDistro/poky
      that referenced
      this pull request
    
      Apr 12, 2023 
    
    
      
  
    
      
    
  
Changelog: =========== - #384: PackageMetadata now stipulates an additional get method allowing for easy querying of metadata keys that may not be present. - #428: packages_distributions now honors packages and modules with Python modules that not .py sources (e.g. .pyc, .so). - #434: Expand protocol for PackageMetadata.get_all to match the upstream implementation of email.message.Message.get_all in python/typeshed#9620. (From OE-Core rev: fde9a92e05c0b01304fa40dba743f9c7b32c628f) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
    
  kraj 
      pushed a commit
        to YoeDistro/poky
      that referenced
      this pull request
    
      Apr 12, 2023 
    
    
      
  
    
      
    
  
Changelog: =========== - #384: PackageMetadata now stipulates an additional get method allowing for easy querying of metadata keys that may not be present. - #428: packages_distributions now honors packages and modules with Python modules that not .py sources (e.g. .pyc, .so). - #434: Expand protocol for PackageMetadata.get_all to match the upstream implementation of email.message.Message.get_all in python/typeshed#9620. (From OE-Core rev: fde9a92e05c0b01304fa40dba743f9c7b32c628f) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
    
  rpurdie 
      pushed a commit
        to yoctoproject/poky
      that referenced
      this pull request
    
      Apr 13, 2023 
    
    
      
  
    
      
    
  
Changelog: =========== - #384: PackageMetadata now stipulates an additional get method allowing for easy querying of metadata keys that may not be present. - #428: packages_distributions now honors packages and modules with Python modules that not .py sources (e.g. .pyc, .so). - #434: Expand protocol for PackageMetadata.get_all to match the upstream implementation of email.message.Message.get_all in python/typeshed#9620. (From OE-Core rev: e3991141939e5e2393cf36edd02ef3765cacd330) Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
    
  halstead 
      pushed a commit
        to openembedded/openembedded-core
      that referenced
      this pull request
    
      Apr 13, 2023 
    
    
      
  
    
      
    
  
Changelog: =========== - #384: PackageMetadata now stipulates an additional get method allowing for easy querying of metadata keys that may not be present. - #428: packages_distributions now honors packages and modules with Python modules that not .py sources (e.g. .pyc, .so). - #434: Expand protocol for PackageMetadata.get_all to match the upstream implementation of email.message.Message.get_all in python/typeshed#9620. Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    
  hauntsaninja 
      added a commit
        to hauntsaninja/pip
      that referenced
      this pull request
    
      Sep 23, 2023 
    
    
      
  
    
      
    
  
Mostly straightforward. The new message.get_all type ignores out of fear it may return None are minorly annoying. You can see some of the extra errors on the pip codebase in the mypy_primer of the typeshed PR that made the change python/typeshed#9620 The abstract errors are because FakeDistribution doesn't actually implement any of the Protocol it claims to implement
    
  hauntsaninja 
      added a commit
        to hauntsaninja/pip
      that referenced
      this pull request
    
      Sep 23, 2023 
    
    
      
  
    
      
    
  
Mostly straightforward. The new message.get_all type ignores out of fear it may return None are minorly annoying. You can see some of the extra errors on the pip codebase in the mypy_primer of the typeshed PR that made the change python/typeshed#9620 The abstract errors are because FakeDistribution doesn't actually implement any of the Protocol it claims to implement
      
     Closed
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Refs #9608. For all of the functions touched here, the
_TTypeVar would go unsolved if no value was passed by the user for thefailobjparameter. We have to use overloads here to ensure that_Twill never silently be resolved asAny