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.

Python restricted dependencies for multiple Python versions fail: 'Array' object has no attribute 'strip'

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Ubuntu 18.10

  • Poetry version: Poetry 0.12.11 (bug does also affect 0.12.10)

  • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/okin/9fca594f2a4ba9917f1c292752d21e4c

Issue

I want to configure an dependency that is only applied when specific Python versions are used. The documentation shows an example that matches my case: pathlib2 = { version = "^2.2", python = ["~2.7", "^3.2"] }

I added this to my project config. Whenever I now try to run poetry install, poetry update or poetry check I am greeted with the following message:

[AttributeError]            
'Array' object has no attribute 'strip'  

No further action is done as poetry appears to break in this case.

Debug output from poetry check

[AttributeError]            
'Array' object has no attribute 'strip'  
                                           
Exception trace:
 /home/wenselowski/.poetry/lib/poetry/_vendor/py3.6/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /home/wenselowski/.poetry/lib/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /home/wenselowski/.poetry/lib/poetry/_vendor/py3.6/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /home/wenselowski/.poetry/lib/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /home/wenselowski/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 /home/wenselowski/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/command.py in execute() at line 107
   return self.handle()
 /home/wenselowski/.poetry/lib/poetry/console/commands/check.py in handle() at line 13
   check_result = self.poetry.check(self.poetry.local_config, strict=True)
 /home/wenselowski/.poetry/lib/poetry/console/commands/command.py in poetry() at line 62
   return self.get_application().poetry
 /home/wenselowski/.poetry/lib/poetry/console/application.py in poetry() at line 60
   self._poetry = Poetry.create(os.getcwd())
 /home/wenselowski/.poetry/lib/poetry/poetry.py in create() at line 148
   package.add_dependency(name, constraint)
 /home/wenselowski/.poetry/lib/poetry/packages/package.py in add_dependency() at line 304
   dependency.python_versions = python_versions
 /home/wenselowski/.poetry/lib/poetry/packages/dependency.py in python_versions() at line 89
   self._python_constraint = parse_constraint(value)
 /home/wenselowski/.poetry/lib/poetry/semver/__init__.py in parse_constraint() at line 19
   or_constraints = re.split(r"\s*\|\|?\s*", constraints.strip())

check

Workaround

No error is shown when configuring it as multiple requirements but no further testing was done if this actually would resolve correctly.

pathlib2 = [
	{ version = "^2.2", python = "~2.7" },
	{ version = "^2.2", python = "^3.2" }
]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
webartifexcommented, Oct 22, 2019

Hi @stephsamson , I was in your tutorial at Pycon.de 😃

Regarding the fix, I chose not to support an older Python version in my project so I have no need for the double pipe any more. However, it is good that you put it in the docs. It was definitely missing there.

Thanks for your time.

0reactions
kastephcommented, Sep 24, 2019

@webartifex does using the double pipe fix your issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poetry - [AttributeError] 'bool' object has no attribute 'strip'
I get this error: $ poetry install Installing dependencies from lock file [AttributeError] 'bool' object has no attribute 'strip'.
Read more >
AttributeError: 'list' object has no attribute 'strip'
The Python "AttributeError: 'list' object has no attribute 'strip'" occurs when we call the strip() method on a list instead of a string....
Read more >
Changelog — Python 3.11.1 documentation
Paths are no longer encoded to UTF-8/strict to avoid encoding errors if it contains surrogate characters (bytes paths are decoded with the surrogateescape...
Read more >
Release Notes — Airflow Documentation
Airflow support for Kubernetes version is described in Installation ... Fix AttributeError : datetime.timezone object has no attribute name (#16599).
Read more >
Understanding JSON Schema
Earlier versions of JSON Schema are not completely compatible with the ... JSON. Python string string number int/float object dict array.
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