diff --git a/Lib/gflanguages/__init__.py b/Lib/gflanguages/__init__.py index 68afcc06..2957742e 100644 --- a/Lib/gflanguages/__init__.py +++ b/Lib/gflanguages/__init__.py @@ -22,11 +22,10 @@ import glob import os +from gflanguages import languages_public_pb2 from google.protobuf import text_format from pkg_resources import resource_filename -from gflanguages import languages_public_pb2 - try: from ._version import version as __version__ # type: ignore except ImportError: @@ -39,10 +38,10 @@ def LoadLanguages(base_dir=DATA_DIR): if base_dir is None: base_dir = DATA_DIR - languages_dir = os.path.join(base_dir, 'languages') + languages_dir = os.path.join(base_dir, "languages") langs = {} - for textproto_file in glob.iglob(os.path.join(languages_dir, '*.textproto')): - with open(textproto_file, 'r', encoding='utf-8') as f: + for textproto_file in glob.iglob(os.path.join(languages_dir, "*.textproto")): + with open(textproto_file, "r", encoding="utf-8") as f: language = text_format.Parse(f.read(), languages_public_pb2.LanguageProto()) langs[language.id] = language return langs @@ -52,10 +51,10 @@ def LoadScripts(base_dir=DATA_DIR): if base_dir is None: base_dir = DATA_DIR - scripts_dir = os.path.join(base_dir, 'scripts') + scripts_dir = os.path.join(base_dir, "scripts") scripts = {} - for textproto_file in glob.iglob(os.path.join(scripts_dir, '*.textproto')): - with open(textproto_file, 'r', encoding='utf-8') as f: + for textproto_file in glob.iglob(os.path.join(scripts_dir, "*.textproto")): + with open(textproto_file, "r", encoding="utf-8") as f: script = text_format.Parse(f.read(), languages_public_pb2.ScriptProto()) scripts[script.id] = script return scripts @@ -65,10 +64,10 @@ def LoadRegions(base_dir=DATA_DIR): if base_dir is None: base_dir = DATA_DIR - regions_dir = os.path.join(base_dir, 'regions') + regions_dir = os.path.join(base_dir, "regions") regions = {} - for textproto_file in glob.iglob(os.path.join(regions_dir, '*.textproto')): - with open(textproto_file, 'r', encoding='utf-8') as f: + for textproto_file in glob.iglob(os.path.join(regions_dir, "*.textproto")): + with open(textproto_file, "r", encoding="utf-8") as f: region = text_format.Parse(f.read(), languages_public_pb2.RegionProto()) regions[region.id] = region return regions diff --git a/dev-requirements.txt b/dev-requirements.txt index 73b0496d..3bc644ab 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,2 +1,5 @@ uharfbuzz youseedee +black +isort +pytest \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 71dfb41d..67ea2c5f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1 @@ ---index-url https://pypi.python.org/simple/ -protobuf==3.19.4 --e . +protobuf==3.19.4 \ No newline at end of file diff --git a/setup.py b/setup.py index 105379ec..3f66ae80 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ 'Programming Language :: Python :: 3' ], python_requires=">=3.7", - setup_requires=['setuptools_scm>=4,<6.1'], + setup_requires=['setuptools_scm'], install_requires=[ # 3.7.0 fixed a bug on parsing some METADATA.pb files. # We cannot use v4 because our protobuf files have been compiled with v3. diff --git a/tox.ini b/tox.ini index fb30fc43..b4ac1c55 100644 --- a/tox.ini +++ b/tox.ini @@ -1,66 +1,23 @@ [tox] -envlist = py37, py38, py39, coverage, flake8, pylint - -[gh-actions] -python = - 3.7: py37, coverage, flake8, pylint - 3.8: py38, coverage, flake8, pylint - 3.9: py39, coverage, flake8, pylint +envlist = lint, py3{7,8,9} +skip_missing_interpreters = true [testenv] deps = - pytest - coverage - -rrequirements.txt - -rdev-requirements.txt -commands = coverage run -m pytest {posargs} -passenv = LD_LIBRARY_PATH LD_PRELOAD - -[testenv:coverage] -deps = coverage -skip_install = true + -r requirements.txt + -r dev-requirements.txt +; download the latest pip, setuptools and wheel when creating the venv +download = true commands = - coverage report - coverage html - -# Exclude a lot of tests here without turning them off in setup.cfg, because a -# developer might want to see and fix them. This is more of a regression test. -[testenv:flake8] -deps = - flake8 - sphinx - sphinx_rtd_theme - recommonmark -commands = flake8 --count --show-source --statistics + pytest tests/ -# Same rationale as with flake8. -[testenv:pylint] +[testenv:lint] +skip_install = true deps = - pylint - sphinx - sphinx_rtd_theme - recommonmark -wont_fix = invalid-name,protected-access,too-many-lines -maybe_someday = fixme,missing-docstring,line-too-long -commands = pylint --disable={[testenv:pylint]wont_fix},{[testenv:pylint]maybe_someday} Lib/gflanguages - -[flake8] -select = E,F,W - -exclude = -# Exclude the entire build directory: - build -# Exclude these auto-generated files that should not be hand-edited: - Lib/gflanguages/languages_public_pb2.py, -# No need to traverse hidden directories such as .git, .tox - .*, -# Exclude virtual environment directory: - venv*, -# There's no value in checking cache directories - __pycache__, -# The Sphinx configuration file is mostly autogenerated, ignore it - docs/source/conf.py, + -r dev-requirements.txt +commands = + black --check --diff Lib/gflanguages --exclude .*pb2.py + isort --check-only Lib/gflanguages --skip Lib/gflanguages/languages_public_pb2.py -max-line-length=100 -ignore = - E126, # continuation line over-indented for hanging indent +[isort] +profile = black \ No newline at end of file