[Git][debian-gis-team/python-cligj][upstream] New upstream version 0.7.0

Bas Couwenberg gitlab at salsa.debian.org
Thu Oct 22 04:49:15 BST 2020



Bas Couwenberg pushed to branch upstream at Debian GIS Project / python-cligj


Commits:
c714c4ce by Bas Couwenberg at 2020-10-22T05:43:16+02:00
New upstream version 0.7.0
- - - - -


4 changed files:

- CHANGES.txt
- cligj/__init__.py
- setup.py
- tests/test_cli.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -1,6 +1,12 @@
 Changes
 =======
 
+0.7.0 (2010-10-21)
+------------------
+
+- Warn about deprecation of support for Python versions < 3.7 in 1.0.0 (#33).
+- Warn about future change in --sequence default when the option is used (#31).
+
 0.6.0 (2020-10-19)
 ------------------
 


=====================================
cligj/__init__.py
=====================================
@@ -4,11 +4,18 @@ A package of arguments, options, and parsers for the Python GeoJSON
 ecosystem.
 """
 
+import sys
+from warnings import warn
+
 import click
 
 from .features import normalize_feature_inputs
 
-# Arguments.
+__version__ = "0.7.0"
+
+if sys.version_info < (3, 7):
+    warn("cligj 1.0.0 will require Python >= 3.7", FutureWarning)
+
 
 # Multiple input files.
 files_in_arg = click.argument(
@@ -99,8 +106,14 @@ sequence_opt = click.option(
     '--sequence/--no-sequence',
     default=False,
     help="Write a LF-delimited sequence of texts containing individual "
-         "objects or write a single JSON text containing a feature "
-         "collection object (the default).")
+    "objects or write a single JSON text containing a feature "
+    "collection object (the default).",
+    callback=lambda ctx, param, value: warn(
+        "Sequences of Features, not FeatureCollections, will be the default in version 1.0.0",
+        FutureWarning,
+    )
+    or value,
+)
 
 use_rs_opt = click.option(
     '--rs/--no-rs',


=====================================
setup.py
=====================================
@@ -2,14 +2,19 @@ from codecs import open as codecs_open
 
 from setuptools import setup, find_packages
 
-# Get the long description from the relevant file
+with open("cligj/__init__.py") as f:
+    for line in f:
+        if "__version__" in line:
+            version = line.split("=")[1].strip().strip('"').strip("'")
+            continue
+
 with codecs_open('README.rst', encoding='utf-8') as f:
     long_description = f.read()
 
 
 setup(
     name="cligj",
-    version="0.6.0",
+    version=version,
     description=u"Click params for commmand line interfaces to GeoJSON",
     long_description=long_description,
     classifiers=[],
@@ -21,6 +26,7 @@ setup(
     packages=find_packages(exclude=["ez_setup", "examples", "tests"]),
     include_package_data=True,
     zip_safe=False,
+    python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4",
     install_requires=["click >= 4.0, < 8"],
     extras_require={"test": ["pytest-cov"],},
 )


=====================================
tests/test_cli.py
=====================================
@@ -1,7 +1,9 @@
 import os
 import os.path
+import sys
 
 import click
+import pytest
 
 import cligj
 
@@ -155,62 +157,67 @@ def test_projection(runner):
     assert result.output.splitlines() == ['geographic']
 
 
-def test_sequence(runner):
+ at pytest.mark.filterwarnings("ignore")
+ at pytest.mark.parametrize(
+    ("opt", "val"),
+    [
+        ("--sequence", True),
+        ("--no-sequence", False),
+        (None, cligj.__version__.startswith("1.0")),
+    ],
+)
+def test_sequence(runner, opt, val):
+    """True becomes the default in 1.0"""
     @click.command()
     @cligj.sequence_opt
     def cmd(sequence):
-        click.echo("%s" % sequence)
+        click.echo(str(sequence))
 
-    result = runner.invoke(cmd)
+    result = runner.invoke(cmd, [opt] if opt is not None else [])
     assert not result.exception
-    assert result.output.splitlines() == ['False']
+    assert result.output.splitlines() == [str(val)]
 
-    result = runner.invoke(cmd, ['--sequence'])
-    assert not result.exception
-    assert result.output.splitlines() == ['True']
 
-    result = runner.invoke(cmd, ['--no-sequence'])
-    assert not result.exception
-    assert result.output.splitlines() == ['False']
+ at pytest.mark.skipif(sys.version_info < (3,), reason="Requires Python 3")
+ at pytest.mark.xfail(cligj.__version__.startswith("1.0"), reason="No warning in 1.0")
+def test_sequence_warns(runner):
+    """Warn about --sequence until 1.0"""
+    @click.command()
+    @cligj.sequence_opt
+    def cmd(sequence):
+        click.echo(str(sequence))
+
+    with pytest.warns(FutureWarning):
+        result = runner.invoke(cmd, ["--sequence"])
 
 
-def test_sequence_rs(runner):
+ at pytest.mark.filterwarnings("ignore")
+ at pytest.mark.parametrize(("opt", "val"), [("--rs", True), (None, False)])
+def test_sequence_rs(runner, opt, val):
     @click.command()
     @cligj.sequence_opt
     @cligj.use_rs_opt
     def cmd(sequence, use_rs):
-        click.echo("%s" % sequence)
-        click.echo("%s" % use_rs)
+        click.echo(str(sequence))
+        click.echo(str(use_rs))
 
-    result = runner.invoke(cmd, ['--sequence', '--rs'])
+    result = runner.invoke(cmd, ["--sequence"] + ([opt] if opt is not None else []))
     assert not result.exception
-    assert result.output.splitlines() == ['True', 'True']
-
-    result = runner.invoke(cmd, ['--sequence'])
-    assert not result.exception
-    assert result.output.splitlines() == ['True', 'False']
+    assert result.output.splitlines() == ["True", str(val)]
 
 
-def test_geojson_type(runner):
+ at pytest.mark.parametrize(
+    ("opt", "val"),
+    [("--collection", "collection"), ("--feature", "feature"), ("--bbox", "bbox")],
+)
+def test_geojson_type(runner, opt, val):
     @click.command()
     @cligj.geojson_type_collection_opt(True)
     @cligj.geojson_type_feature_opt(False)
     @cligj.geojson_type_bbox_opt(False)
     def cmd(geojson_type):
-        click.echo("%s" % geojson_type)
-
-    result = runner.invoke(cmd)
-    assert not result.exception
-    assert result.output.splitlines() == ['collection']
-
-    result = runner.invoke(cmd, ['--collection'])
-    assert not result.exception
-    assert result.output.splitlines() == ['collection']
-
-    result = runner.invoke(cmd, ['--feature'])
-    assert not result.exception
-    assert result.output.splitlines() == ['feature']
+        click.echo(str(geojson_type))
 
-    result = runner.invoke(cmd, ['--bbox'])
+    result = runner.invoke(cmd, [opt])
     assert not result.exception
-    assert result.output.splitlines() == ['bbox']
+    assert result.output.splitlines() == [val]



View it on GitLab: https://salsa.debian.org/debian-gis-team/python-cligj/-/commit/c714c4ce7dca6f165324a8447a4704aeee63a40a

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-cligj/-/commit/c714c4ce7dca6f165324a8447a4704aeee63a40a
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/pkg-grass-devel/attachments/20201022/ec14bce5/attachment-0001.html>


More information about the Pkg-grass-devel mailing list