[med-svn] [Git][med-team/mypy][master] cope with upstream lxml changes

Michael R. Crusoe gitlab at salsa.debian.org
Mon Sep 2 09:37:57 BST 2019



Michael R. Crusoe pushed to branch master at Debian Med / mypy


Commits:
4b2a9bcf by Michael R. Crusoe at 2019-09-02T08:28:50Z
cope with upstream lxml changes

debhelper-compat 12
Standards-Version: 4.4.0
Set upstream metadata fields: Name.

- - - - -


6 changed files:

- debian/changelog
- − debian/compat
- debian/control
- + debian/patches/fix-xml-reports
- + debian/patches/series
- + debian/upstream/metadata


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+mypy (0.720-3) unstable; urgency=medium
+
+  * debhelper-compat 12
+  * Standards-Version: 4.4.0
+  * Set upstream metadata fields: Name.
+  * Pluck patch from upstream to cope with changes to lxml. Closes: #939045
+
+ -- Michael R. Crusoe <michael.crusoe at gmail.com>  Mon, 02 Sep 2019 17:10:54 +0900
+
 mypy (0.720-2) unstable; urgency=medium
 
   * Fix AutoPkgTest path


=====================================
debian/compat deleted
=====================================
@@ -1 +0,0 @@
-12


=====================================
debian/control
=====================================
@@ -4,7 +4,7 @@ Uploaders: Michael R. Crusoe <michael.crusoe at gmail.com>
 Section: utils
 Testsuite: autopkgtest-pkg-python
 Priority: optional
-Build-Depends: debhelper (>= 12~),
+Build-Depends: debhelper-compat (= 12),
                dh-python,
                flake8,
                help2man,
@@ -15,12 +15,13 @@ Build-Depends: debhelper (>= 12~),
                python3-setuptools,
                python3-sphinx <!nodoc>,
                python3-sphinx-rtd-theme <!nodoc>,
-               python3-typed-ast (>= 1.4.0), python3-typed-ast (<< 1.5.0),
+               python3-typed-ast (>= 1.4.0),
+               python3-typed-ast (<< 1.5.0),
                python3-psutil (>= 5.4.0),
-	       python3-mypy-extensions,
-	       python3-typing-extensions,
-	       python3-virtualenv <!nocheck>
-Standards-Version: 4.3.0
+               python3-mypy-extensions,
+               python3-typing-extensions,
+               python3-virtualenv <!nocheck>
+Standards-Version: 4.4.0
 Vcs-Browser: https://salsa.debian.org/med-team/mypy
 Vcs-Git: https://salsa.debian.org/med-team/mypy.git
 Homepage: http://www.mypy-lang.org/
@@ -46,7 +47,6 @@ Section: doc
 Depends: ${misc:Depends},
          ${sphinxdoc:Depends}
 Built-Using: ${sphinxdoc:Built-Using}
-Build-Profiles: <!nodoc>
 Description: documentation for mypy
  Add type annotations to your Python programs, and use mypy to type check them.
  Mypy is essentially a Python linter on steroids, and it can catch many
@@ -55,19 +55,21 @@ Description: documentation for mypy
  gradual typing, generics and union types.
  .
  This package provides the documentation.
+Build-Profiles: <!nodoc>
 
 Package: python3-mypy
 Architecture: all
 Section: python
 Depends: ${misc:Depends},
          ${python3:Depends},
-	 python3-typed-ast,
-	 python3-mypy-extensions,
-	 python3-psutil,
+         python3-typed-ast,
+         python3-mypy-extensions,
+         python3-psutil,
          python3-distutils,
          python3-pkg-resources
 Recommends: python3-lxml
-Breaks: mypy (<< 0.540-2), cwltool (<< 1.0.20181217162649+dfsg-9)
+Breaks: mypy (<< 0.540-2),
+        cwltool (<< 1.0.20181217162649+dfsg-9)
 Replaces: mypy (<< 0.540-2)
 Description: public modules for mypy (Python 3)
  Add type annotations to your Python programs, and use mypy to type check them.


=====================================
debian/patches/fix-xml-reports
=====================================
@@ -0,0 +1,95 @@
+From 4c8e430e92ab290aca6f2147785dcadb26e7c809 Mon Sep 17 00:00:00 2001
+From: Michael Lee <michael.lee.0x2a at gmail.com>
+Date: Mon, 29 Jul 2019 09:31:16 -0700
+Subject: [PATCH] Fix XML attribute order in tests
+
+Our tests recently started breaking -- it turns out this was because
+LXML 4.4.0 was released this Saturday, and LXML apparently respects now
+respects the insertion order of dicts/keyword arguments when setting
+XML attributes.
+
+See the changelog for more details: https://github.com/lxml/lxml/blob/master/CHANGES.txt
+
+I didn't feel like tweaking a bunch of tests, so decided to fix this
+in a relatively lazy way: I just went through every place we instantiated
+an "Element" or "SubElement" object in report.py and manually sorted the
+attributes.
+
+The only exception was the precision info in stats.py -- I discovered to
+my mild surprise that the order of those stats apparently has semantic
+meaning (the higher the number, the less "precise" that line is?), so
+decided it might be more useful to preserve that ordering.
+
+And for good measure, I pinned the LXML test requirement to 4.4.0 so
+we won't need to remember to keep attributes sorted or whatever when
+adding new tests in the future.
+---
+ mypy/report.py                    | 22 +++++++++++-----------
+ test-data/unit/check-reports.test |  2 +-
+ test-requirements.txt             |  2 +-
+ 3 files changed, 13 insertions(+), 13 deletions(-)
+
+--- mypy.orig/mypy/report.py
++++ mypy/mypy/report.py
+@@ -445,10 +445,11 @@
+                 status = visitor.line_map.get(lineno, stats.TYPE_EMPTY)
+                 file_info.counts[status] += 1
+                 etree.SubElement(root, 'line',
+-                                 number=str(lineno),
+-                                 precision=stats.precision_names[status],
++                                 any_info=self._get_any_info_for_line(visitor, lineno),
+                                  content=line_text.rstrip('\n').translate(self.control_fixer),
+-                                 any_info=self._get_any_info_for_line(visitor, lineno))
++                                 number=str(lineno),
++                                 precision=stats.precision_names[status]
++                                 )
+         # Assumes a layout similar to what XmlReporter uses.
+         xslt_path = os.path.relpath('mypy-html.xslt', path)
+         transform_pi = etree.ProcessingInstruction('xml-stylesheet',
+@@ -483,9 +484,9 @@
+         for file_info in output_files:
+             etree.SubElement(root, 'file',
+                              file_info.attrib(),
+-                             total=str(file_info.total()),
++                             module=file_info.module,
+                              name=file_info.name,
+-                             module=file_info.module)
++                             total=str(file_info.total()))
+         xslt_path = os.path.relpath('mypy-html.xslt', '.')
+         transform_pi = etree.ProcessingInstruction('xml-stylesheet',
+                 'type="text/xsl" href="%s"' % pathname2url(xslt_path))
+@@ -517,8 +518,8 @@
+ 
+     def as_xml(self) -> Any:
+         package_element = etree.Element('package',
+-                                        name=self.name,
+-                                        complexity='1.0')
++                                        complexity='1.0',
++                                        name=self.name)
+         package_element.attrib['branch-rate'] = '0'
+         package_element.attrib['line-rate'] = get_line_rate(self.covered_lines, self.total_lines)
+         classes_element = etree.SubElement(package_element, 'classes')
+@@ -559,8 +560,8 @@
+         class_name = os.path.basename(path)
+         file_info = FileInfo(path, tree._fullname)
+         class_element = etree.Element('class',
+-                                      filename=path,
+                                       complexity='1.0',
++                                      filename=path,
+                                       name=class_name)
+         etree.SubElement(class_element, 'methods')
+         lines_element = etree.SubElement(class_element, 'lines')
+@@ -582,10 +583,10 @@
+                     branch = True
+                 file_info.counts[status] += 1
+                 line_element = etree.SubElement(lines_element, 'line',
+-                                                number=str(lineno),
+-                                                precision=stats.precision_names[status],
++                                                branch=str(branch).lower(),
+                                                 hits=str(hits),
+-                                                branch=str(branch).lower())
++                                                number=str(lineno),
++                                                precision=stats.precision_names[status])
+                 if branch:
+                     line_element.attrib['condition-coverage'] = '50% (1/2)'
+             class_element.attrib['branch-rate'] = '0'


=====================================
debian/patches/series
=====================================
@@ -0,0 +1 @@
+fix-xml-reports


=====================================
debian/upstream/metadata
=====================================
@@ -0,0 +1 @@
+Name: mypy



View it on GitLab: https://salsa.debian.org/med-team/mypy/commit/4b2a9bcf4ceffcb2b055cb43bb41233bdf73c1bd

-- 
View it on GitLab: https://salsa.debian.org/med-team/mypy/commit/4b2a9bcf4ceffcb2b055cb43bb41233bdf73c1bd
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190902/0654b2e3/attachment-0001.html>


More information about the debian-med-commit mailing list