question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

1.1.0: TypeError: installed_distributions() got an unexpected keyword argument 'paths'

See original GitHub issue

Bug description

I tried running the self tests for 1.1.0 using the github source file on NetBSD.

Reproduction steps

Build, and run pytest.

Screenshots and logs

___________________________________________________________ test_pip_source ___________________________________________________________
                                                                                                                                       
self = <pip_audit._dependency_source.pip.PipSource object at 0x77deac90a910>
                                                                                                                                                                                                                                                                                           
    def collect(self) -> Iterator[Dependency]:                                                                                         
        """                                                           
        Collect all of the dependencies discovered by this `PipSource`.                                                                      
                                                                                                                                             
        Raises a `PipSourceError` on any errors.                      
        """                                                                                                                                  
                                                                                                                                             
        # The `pip list` call that underlies `pip_api` could fail for myriad reasons.                                                        
        # We collect them all into a single well-defined error.       
        try:                                                          
>           for (_, dist) in pip_api.installed_distributions(         
                local=self._local, paths=list(self._paths)            
            ).items():                                                
E           TypeError: installed_distributions() got an unexpected keyword argument 'paths'                                                  

pip_audit/_dependency_source/pip.py:72: TypeError                     

The above exception was the direct cause of the following exception:                                                                         

    def test_pip_source():                                            
        source = pip.PipSource()                                      
                                                                      
        # We're running under pytest, so we can safely assume that pytest is in                                                              
        # our execution environment. We're also running pip_audit itself, so we                                                              
        # can safely test for ourselves.                              
        pytest_spec = ResolvedDependency(name="pytest", version=Version(pytest.__version__))                                                 
        pip_audit_spec = ResolvedDependency(name="pip-audit", version=Version(pip_audit.__version__))                                        
                                                                      
>       specs = list(source.collect())                                

test/dependency_source/test_pip.py:24:                                
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _      

self = <pip_audit._dependency_source.pip.PipSource object at 0x77deac90a910>                                                                 

    def collect(self) -> Iterator[Dependency]:                        
        """                                                           
        Collect all of the dependencies discovered by this `PipSource`.                                                                      
                                                                      
        Raises a `PipSourceError` on any errors.                      
        """                                                           
                                                                      
        # The `pip list` call that underlies `pip_api` could fail for myriad reasons.                                                        
        # We collect them all into a single well-defined error.       
        try:                                                          
            for (_, dist) in pip_api.installed_distributions(         
                local=self._local, paths=list(self._paths)            
            ).items():                                                
                dep: Dependency                                       
                try:                                                  
                    dep = ResolvedDependency(name=dist.name, version=Version(str(dist.version)))                                             
                    if self.state is not None:                        
                        self.state.update_state(                      
                            f"Collecting {dep.name} ({dep.version})"                                                                         
                        )  # pragma: no cover                         
                except InvalidVersion:                                
                    skip_reason = (                                   
                        "Package has invalid version and could not be audited: "                                                             
                        f"{dist.name} ({dist.version})"               
                    )                                                 
                    logger.debug(skip_reason)                         
                    dep = SkippedDependency(name=dist.name, skip_reason=skip_reason)                                                         
                yield dep                                             
        except Exception as e:                                        
>           raise PipSourceError("failed to list installed distributions") from e                                                            
E           pip_audit._dependency_source.pip.PipSourceError: failed to list installed distributions                                          

pip_audit/_dependency_source/pip.py:91: PipSourceError                

Platform information

  • NetBSD 9.99.82
  • pip-audit 1.1.0
  • python 3.9.9
  • pip 21.3.1

Other

One other test is failing, the one that’s trying to install ansible-core. But that’s just a reminder since you said you’d find a way to disable this one.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
0-wiz-0commented, Dec 7, 2021

But pip-audit works fine now!

# pip-audit
No known vulnerabilities found
0reactions
0-wiz-0commented, Dec 8, 2021

8d3e813 removes the flaky assertion. It’s one of a pair, so the coverage/correctness of the test suite isn’t affected.

Yes, that fixes the test failure for me. Now I just have the one where it wants to install ansible-core. Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TypeError] distributions() got an unexpected keyword ...
If an exception occurs when executing a command, I executed it again in debug mode ( -vvv option). Poetry Version: 1.0.0 Python: 3.6.8 ......
Read more >
custom() got an unexpected keyword argument 'path ...
Try to re-clone the repository and place your model in "/home/runs/train/yolov7x-custom/weights" path, or easily you can clone the repo ...
Read more >
TypeError: __init__() got an unexpected keyword argument ...
Hi, I have followed the steps given in the chapter to set up mflix app. ... TypeError: init() got an unexpected keyword argument...
Read more >
What's new in 1.1.0 (July 28, 2020)
The DataFrame.to_feather() method now supports additional keyword arguments (e.g. to set the compression) that are added in pyarrow 0.17 (GH33422).
Read more >
TypeError: copy() got an unexpected keyword argument ' ...
currently we have 2 prediction model and we setup the prediction model in ... TypeError: copy() got an unexpected keyword argument 'deep'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found