Skip to content

Commit

Permalink
Merge pull request #32 from Safe/cib-fixes
Browse files Browse the repository at this point in the history
Fix Python 3.8 support; various misc fixes and improvements
  • Loading branch information
carsonyl authored and GitHub Enterprise committed Jul 15, 2024
2 parents 6646cfd + c65cecb commit b57077a
Show file tree
Hide file tree
Showing 23 changed files with 124 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ instance/

# Sphinx documentation
docs/_build/
_build/

# PyBuilder
target/
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# fmetools changes

## 0.9.4

* Fix support for Python 3.8 and require Python 3.8+.

## 0.9.3

* Update docstrings for FMEEnhancedTransformer and FMEBaseTransformer.
Expand Down
5 changes: 4 additions & 1 deletion fme_env.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A CLI script to set up a virtualenv to work with FME.
"""

import os
import argparse
import shutil
Expand Down Expand Up @@ -31,7 +32,9 @@
raise ValueError("Couldn't find " + site_packages_dir)

if not args.fme_home:
raise ValueError("FME_HOME environment variable not defined, so --fme-home must be given")
raise ValueError(
"FME_HOME environment variable not defined, so --fme-home must be given"
)
print("Using FME install dir: " + args.fme_home)
if not os.path.isdir(args.fme_home):
raise ValueError("FME_HOME is not a directory")
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ addopts = "-s"
testpaths = [
"tests",
]

[tool.ruff]
required-version = '>=0.5.1'
target-version = 'py38'
[tool.ruff.lint]
extend-select = ["FA"]
11 changes: 6 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
build
pytest
pytest-vcr
hypothesis
ruff
build==1.2.1
pytest>=8.2.2
pytest-cov>=5.0.0
pytest-vcr==1.0.2
hypothesis==6.105.1
ruff==0.5.1
78 changes: 35 additions & 43 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,43 +1,35 @@
[metadata]
name = fmetools
version = attr: fmetools.__version__
author = Safe Software Inc.
description = Tools for extending Safe Software's FME using Python.
long_description = file: README.md, CHANGES.md
long_description_content_type = text/markdown
keywords = FME fmeobjects
url = https://github.com/safesoftware/fmetools
project_urls =
Documentation = https://docs.safe.com/fme/html/fmetools/
license = BSD
license_file = LICENSE
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
License :: OSI Approved :: BSD License
Intended Audience :: Developers
[options]
package_dir =
=src
packages = find:
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*
include_package_data = True
[options.packages.find]
where=src
[options.extras_require]
dev =
ruff>=0.1.5
pytest
hypothesis
sphinx>=6.0.0
sphinx-rtd-theme>=1.2.2
[bdist_wheel]
universal=1
[metadata]
name = fmetools
version = attr: fmetools.__version__
author = Safe Software Inc.
description = Tools for extending Safe Software's FME using Python.
long_description = file: README.md, CHANGES.md
long_description_content_type = text/markdown
keywords = FME fmeobjects
url = https://github.com/safesoftware/fmetools
project_urls =
Documentation = https://docs.safe.com/fme/html/fmetools/
license = BSD
license_file = LICENSE
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
License :: OSI Approved :: BSD License
Intended Audience :: Developers
[options]
package_dir =
=src
packages = find:
python_requires = >=3.8.0
include_package_data = True
[options.packages.find]
where=src
[bdist_wheel]
universal=1
2 changes: 1 addition & 1 deletion src/fmetools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8

__version__ = "0.9.3"
__version__ = "0.9.4"

import gettext
import os
Expand Down
1 change: 1 addition & 0 deletions src/fmetools/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
These utilities make it more convenient to work with FMEFeature objects,
and help avoid common errors.
"""

from __future__ import annotations

from typing import Any, Iterable, Optional
Expand Down
3 changes: 3 additions & 0 deletions src/fmetools/guiparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
This module is made available to provide a migration path for existing transformers and advanced use cases.
Most developers should instead use FMXJ transformer definitions and :mod:`fmetools.paramparsing`.
"""

from __future__ import annotations

from collections import namedtuple
from typing import Any, Mapping, Union

Expand Down
2 changes: 2 additions & 0 deletions src/fmetools/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
a drop-in replacement for :class:`requests.Session`.
Use this class to make HTTP requests that automatically follow FME settings.
"""

from __future__ import annotations
import json
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions src/fmetools/localize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Helpers for enabling localized strings using the :mod:`gettext` module.
"""

from __future__ import annotations

import os
Expand Down
3 changes: 3 additions & 0 deletions src/fmetools/logfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
Developers should not need to directly use anything in this module,
as the base classes in :mod:`.plugins` include preconfigured loggers.
"""

from __future__ import annotations

import logging
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions src/fmetools/paramparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Packages using this module and targeting both FME Form and FME Flow
should set ``minimum_fme_build`` in its package.yml accordingly.
"""

from __future__ import annotations

from typing import Any, Iterable, Optional, Union
Expand Down
5 changes: 3 additions & 2 deletions src/fmetools/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
This module contains parsers to support FME reader/writer development.
It is not intended for general use.
"""

from collections import OrderedDict, namedtuple

import fme
import six
from fmeobjects import FMEFeature, FMESession
from pluginbuilder import FMEMappingFile
from fmeobjects import FMEFeature, FMESession # noqa F401
from pluginbuilder import FMEMappingFile # noqa F401
from six import string_types

from .utils import string_to_bool
Expand Down
3 changes: 3 additions & 0 deletions src/fmetools/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
:class:`FMEEnhancedTransformer` is the recommended base class for transformers.
Transformer developers should subclass it to implement their own transformers.
"""

from __future__ import annotations

import logging
import warnings
from typing import Optional
Expand Down
3 changes: 3 additions & 0 deletions src/fmetools/scripted_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
which includes a reference to the :class:`ScriptedSelectionCallback` implementation above,
and other configuration, such as Input Parameters, search support, and more.
"""

from __future__ import annotations

from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional

Expand Down
1 change: 1 addition & 0 deletions src/fmetools/webservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Helpers for working with FME Named Connections and FME Web Services.
"""

from __future__ import annotations

from typing import Union
Expand Down
Empty file removed tests/__init__.py
Empty file.
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# coding: utf-8
# Import these modules just for parsing coverage.
# Remove when these modules get imported elsewhere for tests.
from fmetools import localize, scripted_selection, webservices # noqa F401

import json

Expand Down
4 changes: 3 additions & 1 deletion tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def test_set_and_get_attributes(attrs):


def test_build_feature():
f = build_feature("feattype", attrs={"foo": "bar"}, geometry=FMEPoint(1, 1, 1), coordsys="LL84")
f = build_feature(
"feattype", attrs={"foo": "bar"}, geometry=FMEPoint(1, 1, 1), coordsys="LL84"
)
assert not f.getSequencedAttributeNames()
assert f.getFeatureType() == "feattype"
assert isinstance(f.getGeometry(), FMEPoint)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fmehttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_generalproxyhandler_use_system_proxy_flag(value):
mockSession = MockFMESession(["use-system-proxy", value])
handler = FMEGeneralProxyHandler()
handler.configure(mockSession)
assert handler.use_pac == (value is "yes")
assert handler.use_pac == (value == "yes")


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_paramparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@pytest.fixture
def creator():
return TransformerParameterParser("Creator")
return TransformerParameterParser("Creator", version=6)


def test_system_transformer(creator):
Expand Down
38 changes: 38 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[tox]
envlist = py{38,39,310,311,312}
min_version = 4.16.0
package = editable

[testenv]
passenv =
FME_HOME
deps =
pytest>=8.2.2
pytest-cov>=5.0.0
pytest-vcr>=1.0.2
hypothesis>=6.105.1
fme-packager>=1.6.0
commands =
fme-packager config-env --fme-home '{env:FME_HOME}'
pytest --junitxml test-reports/junit-{envname}.xml --junit-prefix={envname} --cov --cov-append --cov-report xml {posargs}

[testenv:format]
deps =
ruff>=0.3.2
skip_install = true
commands =
ruff format --check

[testenv:check]
deps =
ruff>=0.3.2
skip_install = true
commands =
ruff check

[testenv:docs]
deps =
sphinx>=6.0.0
sphinx-rtd-theme>=1.2.2
commands =
sphinx-build docs _build

0 comments on commit b57077a

Please sign in to comment.