Patchwork D1037: check-code: suggest pycompat.is(posix|windows|darwin)

login
register
mail settings
Submitter phabricator
Date Oct. 13, 2017, 2:06 p.m.
Message ID <4a66cfd56cacb31a1050ce1d7721fa40@localhost.localdomain>
Download mbox | patch
Permalink /patch/24832/
State Not Applicable
Headers show

Comments

phabricator - Oct. 13, 2017, 2:06 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4889b84b15f2: check-code: suggest pycompat.is(posix|windows|darwin) (authored by quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1037?vs=2659&id=2686

REVISION DETAIL
  https://phab.mercurial-scm.org/D1037

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS




To: quark, #hg-reviewers, spectral
Cc: mercurial-devel

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -397,6 +397,18 @@ 
           (?P=quote))""", reppython),
 ]
 
+# non-filter patterns
+pynfpats = [
+    [
+    (r'pycompat\.osname\s*[=!]=\s*[\'"]nt[\'"]', "use pycompat.iswindows"),
+    (r'pycompat\.osname\s*[=!]=\s*[\'"]posix[\'"]', "use pycompat.isposix"),
+    (r'pycompat\.sysplatform\s*[!=]=\s*[\'"]darwin[\'"]',
+     "use pycompat.isdarwin"),
+    ],
+    # warnings
+    [],
+]
+
 # extension non-filter patterns
 pyextnfpats = [
     [(r'^"""\n?[A-Z]', "don't capitalize docstring title")],
@@ -513,6 +525,7 @@ 
 
 checks = [
     ('python', r'.*\.(py|cgi)$', r'^#!.*python', pyfilters, pypats),
+    ('python', r'.*\.(py|cgi)$', r'^#!.*python', [], pynfpats),
     ('python', r'.*hgext.*\.py$', '', [], pyextnfpats),
     ('python 3', r'.*(hgext|mercurial)/(?!demandimport|policy|pycompat).*\.py',
      '', pyfilters, py3pats),