【问题标题】:isort sorting things differently when running locally than in CI/other machines在本地运行时与在 CI/其他机器中运行时的排序方式不同
【发布时间】:2022-08-24 18:49:52
【问题描述】:

在本地运行 isort 时(例如 python -m isort .poetry run isort .isort 似乎对事物进行排序与​​ CI 中的不同,因此当我的 CI 作业使用 python -m isort --check-only . 检查格式是否正确时会失败。

正确的:

import azure
import pytest

from my_package_name.example import Example1, Example2

错误,本地运行

import azure

import pytest
from my_package_name.example import Example1, Example2

    标签: python isort


    【解决方案1】:

    原因

    我有一个名为pytest 的空文件夹,这欺骗了isort 认为它是一个本地模块。

    因此,它将import pytest 与其他本地导入一起移动。

    解决方案

    删除这个空文件夹后,isort 再次对导入进行了正确排序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-10
      • 1970-01-01
      • 1970-01-01
      • 2019-09-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多