我有一些我在import matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
NPoints_Phi = 30
NPoints_Theta = 30
radius = 1
pi = np.pi
cos = np.cos
sin = np.sin
phi_array = ((np.linspace(0, 1, NPoints_Phi))**1) * 2*pi
theta_array = (np.linspace(0, 1, NPoints_Theta) **1) * pi
phi, theta = np.meshgrid(phi_array, theta_array)
x_coord = radius*sin(theta)*cos(phi)
y_coord = radius*sin(theta)*sin(phi)
z_coord = radius*cos(theta)
#Make colormap the fourth dimension
color_dimension = x_coord
minn, maxx = color_dimension.min(), color_dimension.max()
norm = matplotlib.colors.Normalize(minn, maxx)
m = plt.cm.ScalarMappable(norm=norm, cmap='jet')
m.set_array([])
fcolors = m.to_rgba(color_dimension)
theta2 = np.linspace(-np.pi, 0, 1000)
phi2 = np.linspace( 0 , 5 * 2*np.pi , 1000)
x_coord_2 = radius * np.sin(theta2) * np.cos(phi2)
y_coord_2 = radius * np.sin(theta2) * np.sin(phi2)
z_coord_2 = radius * np.cos(theta2)
# plot
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(x_coord_2, y_coord_2, z_coord_2,'k|-', linewidth=1 )
ax.plot_surface(x_coord,y_coord,z_coord, rstride=1, cstride=1, facecolors=fcolors, vmin=minn, vmax=maxx, shade=False)
fig.show()
运行的python代码,我决定也运行pylint
。
为避免with语句中的长行,我执行以下操作:
pycodestyle
但with my_context_manager(
argument1,
argument2) as something:
rest_of_my_code
告诉我
pycodestyle
所以我进一步缩进,如下:
E125 continuation line with same indent as next logical line
但现在with my_context_manager(
argument1,
argument2) as something:
rest_of_my_code
告诉我:
pylint
是否有更好的解决方案可以满足代码质量检查器的需要?
注1
如果线条不太长(以下情况并非总是如此),以下两种风格的检查器都没有提出任何投诉:
Wrong hanging indentation (remove 4 spaces).
注2
要回答评论,我尝试了以下内容:
with my_context_manager(argument1,
argument2) as something:
rest_of_my_code
奇怪地with my_context_manager(
argument1,
argument2) as something:
rest_of_my_code
仍然说pycodestyle
与之前相同的行(E125 continuation line with same indent as next logical line
)。
答案 0 :(得分:3)
我按以下方式格式化了代码......
with my_context_manager(
argument1,
argument2
) as something:
rest_of_my_code
......并没有得到任何来自pylint和pycodestyle的投诉。
答案 1 :(得分:2)
您可以在列表中禁用签入检查(在.pylintrc中添加 SELECT row_number() over (order by (select null)) as id, u.sku
FROM [dbo].[TBL_Sku2]
UNPIVOT (
Sku
FOR SkuName IN (
[SKU1]
,[SKU2]
,[SKU3]
,[SKU4]
,[SKU5]
,[SKU6]
)) AS u;
)到文件的 MESSAGE CONTROL 部分中的bad-continuation
选项。
〜/ .pylintrc
disable
有关message-control config
的更多信息,请参阅常见问题解答