Package: python-poseur
poseurWritepositional-only parametersin Python 3.8 flavour, and letposeurworry about back-port issues :beer:SincePEP 570, Python introducedpositional-only parameterssyntax in version3.8. For those who wish to usepositional-only parametersin their code,poseurprovides an
intelligent, yet imperfect, solution of abackport compilerby removingpositional-only parameterssyntax whilst
introducing adecoratorfor runtime checks, which guarantees you to always writepositional-only parametersin Python
3.8 flavour then compile for compatibility later.InstallationNote thatposeuronly supports Python versionssince 3.3🐍For macOS users,poseuris now available throughHomebrew:brewtapjarryshaw/tap
brewinstallposeur# or simply, a one-linerbrewinstalljarryshaw/tap/poseurSimply run the following to install the current version from PyPI:pipinstallposeurOr install the latest version from the git repository:gitclonehttps://github.com/JarryShaw/poseur.gitcdposeur
pipinstall-e.# and to update at any timegitpullBasic UsageCLIIt is fairly straightforward to useposeur:context in${...}changes dynamically according to runtime environmentusage: poseur [options] <python source files and folders...>

Back-port compiler for Python 3.8 positional-only parameters.

positional arguments:
  SOURCE                python source files and folders to be converted (${CWD})

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -q, --quiet           run in quiet mode

archive options:
  duplicate original files in case there's any issue

  -n, --no-archive      do not archive original files
  -p PATH, --archive-path PATH
                        path to archive original files (${CWD}/archive)

convert options:
  compatibility configuration for non-unicode files

  -c CODING, --encoding CODING
                        encoding to open source files (${LOCALE_ENCODING})
  -v VERSION, --python VERSION
                        convert against Python version (${LATEST_VERSION})
  -s SEP, --linesep SEP
                        line separator to process source files (${OS_LINESEP})
  -d, --dismiss         dismiss runtime checks for positional-only parameters
  -nl, --no-linting     do not lint converted codes
  -r VAR, --decorator VAR
                        name of decorator for runtime checks (${DECORATOR})
  -t INDENT, --tabsize INDENT
                        indentation tab size (4)poseurwill read then convert allpositional-only parameterssyntax in every Python
file under this path. In case there might be some problems with the conversion,poseurwill
duplicate all original files it is to modify intoarchivedirectory ahead of the process,
if-nnot set.Besides, to keep consistency of API to users,poseurships with adecoratorfor
such functions to check positional-only parameters at runtime, if-nlnot set.Developer ReferenceEnvironmentsposeurcurrently supports three environment arguments:POSEUR_QUIET-- run in quiet mode (same as--quietoption in CLI)POSEUR_VERSION-- convert against Python version (same as--pythonoption in CLI)POSEUR_ENCODING-- encoding to open source files (same as--encodingoption in CLI)POSEUR_LINESEP-- line separator to process source files (same as--linesepoption in CLI)POSEUR_DISMISS-- dismiss runtime checks for positional-only arguments (same as--dismissoption in CLI)POSEUR_LINTING-- lint converted codes (same as--lintingoption in CLI)POSEUR_DECORATOR-- name of decorator for runtime checks (same as--decoratoroption in CLI)POSEUR_TABSIZE-- indentation tab size (same as--tabsizeoption in CLI)APIsposeur-- wrapper works for conversionposeur(filename)Args:filename--str, file to be convertedEnvs:POSEUR_QUIET-- run in quiet mode (same as--quietoption in CLI)POSEUR_ENCODING-- encoding to open source files (same as--encodingoption in CLI)POSEUR_VERSION-- convert against Python version (same as--pythonoption in CLI)POSEUR_LINESEP-- line separator to process source files (same as--linesepoption in CLI)POSEUR_DISMISS-- dismiss runtime checks for positional-only arguments (same as--dismissoption in CLI)POSEUR_LINTING-- lint converted codes (same as--lintingoption in CLI)POSEUR_DECORATOR-- name of decorator for runtime checks (same as--decoratoroption in CLI)POSEUR_TABSIZE-- indentation tab size (same as--tabsizeoption in CLI)Raises:ConvertError-- when source code contains syntax errorsconvert-- the main conversion processconvert(string,source='<unknown>')Args:string--str, context to be convertedsource--str, source of the contextEnvs:POSEUR_VERSION-- convert against Python version (same as--pythonoption in CLI)POSEUR_LINESEP-- line separator to process source files (same as--linesepoption in CLI)POSEUR_DISMISS-- dismiss runtime checks for positional-only arguments (same as--dismissoption in CLI)POSEUR_LINTING-- lint converted codes (same as--lintingoption in CLI)POSEUR_DECORATOR-- name of decorator for runtime checks (same as--decoratoroption in CLI)POSEUR_TABSIZE-- indentation tab size (same as--tabsizeoption in CLI)Returns:str-- converted stringRaises:ConvertError-- when source code contains syntax errorsInternal exceptionsclassConvertError(SyntaxError):"""Parso syntax error."""classEnvironError(EnvironmentError):"""Invalid environment."""TestSeetest.py.ContributionContributions are very welcome, especially fixing bugs and providing test cases.
Note that code must remain valid and reasonable.See Alsobabelf2formatwalrusvermin