Pergunta

I am getting a pep8 markup error on this piece of code.(see below).

urlpatterns = patterns('',
                      (r'', include(v1_api.urls)),
                       url(
                       r"^ajax/photos/upload/(?P<slug>[-_\w]+)/$",
                       "medicms.views.upload_photos",
                       name="upload_photos"
                      ),
                       url(
                       r"^ajax/photos/recent/$",
                       "medicms.views.recent_photos",
                       name="recent_photos"
                      ),
                      )

I am using jenkins to fix lint and pep8 errors. I need to reduce all my lines of code below 79 characters. These lines are below 79 but jenkins is saying 127 > 79 on line 3, 106 > 79 on line 4.

It looks like i have indentation errors and jenkins is reading two lines of code where it should be reading one. Can anyone see any obvious errors that i am not picking up? Or does anyone know if this is a known issue with jenkins? Thanks

Foi útil?

Solução

I don't find any errors; I can only guess that jenkins is incorrect. Running pep8 does produce 3 times the warning E124 closing bracket does not match visual indentation, which is probably also why jenkins complains here.

For this particular case (Django URL patterns), I tend to align things as follows:

urlpatterns = patterns(
    '',
    (r'', include(v1_api.urls)),
    url(
        r"^ajax/photos/upload/(?P<slug>[-_\w]+)/$",
        "medicms.views.upload_photos",
        name="upload_photos"
    ),
    url(
        r"^ajax/photos/recent/$",
        "medicms.views.recent_photos",
        name="recent_photos"
    ),
)

which at least shuts up pep8, and makes for shorter lines overall.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top