「botocore.vendored」のrequestsとurllib3は、そのうち使えなくなります。 Lambda等で使用中の場合は忘れないうちに対応しましょう!

botocore.vendoredのrequestsとurllib3は、そのうち使えなくなります。 「from botocore.vendored import requests」などと使っている場合は、早めに対応しましょう。
2019.05.14

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

はじめに

サーバーレス開発部の藤井元貴です。

こんな会話がありました。

  • 藤井「あ、Lambdaにrequests入れるの忘れた」
  • ○○「from botocore.vendored import requestsって出来るで」
  • 藤井「なんだって! 便利!」

〜〜 調べてみる 〜〜

  • 藤井「非推奨やん! そのうち消えるやん!!」
  • ○○「やっぱり?」

使ってる方は使わないようにしましょうというブログです。

公式情報

botocoreの公式ドキュメントに記載が有りました。

The vendored versions of requests and urllib3 are no longer being used and have been replaced with a direct dependency on upstream urllib3 and requests is no longer a dependency of botocore. While these vendored dependencies are still in the botocore package they should not be used as they will be removed in the future. Any code that imports from botocore.vendored.requests.* should be updated accordingly. Specifically, the use of botocore.vendored.requests.exceptions.* or botocore.vendored.requests.packages.urllib3.exceptions.* must be updated to the corresponding exception classes in botocore.exceptions.

つまりこうです。

  • botocore.vendored.requestsbotocore.vendored.urllib3は、もう使われてないよ
  • 今はbotocoreに入ってるけど、将来的に削除されるので、使わないでね

どうすれば?

botocore.vendoredrequestsurllib3は使用せず、自前でライブラリを用意しましょう。

さいごに

botocoreの公式ドキュメントでは、「いつまで使えるのか?」は言及されていませんが、使用している場合は、早めに対応すると安心ですね。

参考