aboutsummaryrefslogtreecommitdiff
From 397463014fda3cdefe8d6c9d117ae16d878dc494 Mon Sep 17 00:00:00 2001
From: Michael Hudson-Doyle <michael.hudson@canonical.com>
Date: Tue, 25 Sep 2018 14:58:57 +1200
Subject: [PATCH] Keep compability with stdlib tokenize.py changes

https://github.com/python/cpython/commit/c4ef4896eac86a6759901c8546e26de4695a1389
is not yet part of any release of Python but has been backported to all
versions in Git (includeing 2.7!). It causes the tokenize.py module to
emit a synthetic NEWLINE token for files that do not in fact end with a
newline, which confuses pycodestyle's checks for blank lines at the end
of a file. Fortunately the synthetic NEWLINE tokens are easy to detect
(the token text is "").

Fixes #786
---
 pycodestyle.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pycodestyle.py b/pycodestyle.py
index 0d725d27..fbc3dca3 100755
--- a/pep8.py
+++ b/pep8.py
@@ -258,10 +258,10 @@ def trailing_blank_lines(physical_line, lines, line_number, total_lines):
     """
     if line_number == total_lines:
         stripped_last_line = physical_line.rstrip()
-        if not stripped_last_line:
+        if physical_line and not stripped_last_line:
             return 0, "W391 blank line at end of file"
         if stripped_last_line == physical_line:
-            return len(physical_line), "W292 no newline at end of file"
+            return len(lines[-1]), "W292 no newline at end of file"
 
 
 @register_check
//bugs.gnu.org/22588>. Reported by Mark H Weaver <mhw@netris.org>. * gnu/build/file-systems.scm (check-file-system): Pass %BOURNISH-LANGUAGE as the argument to 'start-repl'. * gnu/services.scm (activation-script): Add (guix build bournish). * gnu/services/base.scm (file-system-shepherd-service)[imported-modules]: Likewise. * gnu/system/linux-container.scm (container-script): Likewise. * gnu/system/vm.scm (expression->derivation-in-linux-vm): Likewise. 2015-11-02services: Add 'system-service-type'.Ludovic Courtès * gnu/services.scm (system-derivation): New procedure. (system-service-type): New variable. (boot-script-entry): New procedure. (boot-service-type): Extend SYSTEM-SERVICE-TYPE. (etc-entry): New procedure. (etc-service-type): Extend SYSTEM-SERVICE-TYPE. (fold-services): Change default #:target-type to SYSTEM-SERVICE-TYPE. * gnu/system.scm (operating-system-directory-base-entries): New procedure. (essential-services): Use it. Add an instance of SYSTEM-SERVICE-TYPE. (operating-system-boot-script): Pass #:target-type to 'fold-services'. (operating-system-derivation): Rewrite in terms of 'fold-services'. * gnu/system/linux-container.scm (system-container): Remove. (container-script): Use 'operating-system-derivation'. * guix/scripts/system.scm (export-extension-graph): Replace BOOT-SERVICE-TYPE by SYSTEM-SERVICE-TYPE. * doc/images/service-graph.dot: Add 'system' node and edges. * doc/guix.texi (Service Composition): Mention SYSTEM-SERVICE-TYPE. (Service Reference): Document it. Update 'fold-services' documentation. 2015-10-30scripts: system: Add 'container' action.David Thompson * guix/scripts/system.scm (show-help): Display 'container' action. (system-derivation-for-action, guix-system): Add 'container' case. (perform-action): Skip GRUB config generation when building a container. * doc/guix.texi (Invoking guix system): Document it. 2015-10-30system: container: Adjust to changes in gexps.David Thompson * gnu/system/linux-container.scm (system-container): 'etc' is no longer a monadic value, and the result of 'file-union' must be lowered. 2015-09-14gnu: system: Add Linux container module.David Thompson * gnu/system/linux-container.scm: New file. * gnu-system.am (GNU_SYSTEM_MODULES): Add it. * gnu/system.scm: Export 'operating-system-etc-directory', 'operating-system-boot-script', 'operating-system-locale-directory', and 'file-union'. (operating-system-boot-script): Add #:container? keyword argument. (operating-system-activation-script): Add #:container? keyword argument. Don't call 'activate-firmware' or 'activate-ptrace-attach' when activating a container.