-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python: Switch to pyproject.toml #290
Changes from 4 commits
07cb344
afbba91
f1cd4e1
1c5114c
b94911b
5405b62
9f7f9cc
d992ac4
987e836
dc520a1
3ed84b3
58bef75
4a9d3b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import sys | ||
|
||
from gherkin.token_scanner import TokenScanner | ||
from gherkin.token_formatter_builder import TokenFormatterBuilder | ||
from gherkin.parser import Parser | ||
|
||
|
||
def main() -> int: | ||
files = sys.argv[1:] | ||
parser = Parser(TokenFormatterBuilder()) | ||
for file in files: | ||
scanner = TokenScanner(file) | ||
print(parser.parse(scanner)) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
raise SystemExit(main()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BAD IDEA:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I prefer the latter just because it avoids an import. Wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is not really a side-effect. You may argue that also in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed this is mainly a styling thing from what I can see, unless I am mistaken? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, it is not. It is the difference between using the official API for something and programming by side-effects.
SEE ALSO: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this programming by side effect? Where is the side effect here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. anyway, I removed |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from optparse import OptionParser | ||
import json | ||
|
||
from gherkin.stream.gherkin_events import GherkinEvents | ||
from gherkin.stream.source_events import SourceEvents | ||
|
||
|
||
def create_arg_parser() -> OptionParser: | ||
parser = OptionParser() | ||
parser.add_option( | ||
"--no-source", | ||
action="store_false", | ||
dest="print_source", | ||
default=True, | ||
help="don't print source events", | ||
) | ||
parser.add_option( | ||
"--no-ast", | ||
action="store_false", | ||
dest="print_ast", | ||
default=True, | ||
help="don't print ast events", | ||
) | ||
parser.add_option( | ||
"--no-pickles", | ||
action="store_false", | ||
dest="print_pickles", | ||
default=True, | ||
help="don't print pickle events", | ||
) | ||
return parser | ||
|
||
|
||
def main() -> int: | ||
arg_parser = create_arg_parser() | ||
|
||
options, args = arg_parser.parse_args() | ||
|
||
source_events = SourceEvents(args) | ||
gherkin_events = GherkinEvents( | ||
GherkinEvents.Options( | ||
print_source=options.print_source, | ||
print_ast=options.print_ast, | ||
print_pickles=options.print_pickles, | ||
) | ||
) | ||
|
||
for source_event in source_events.enum(): | ||
for event in gherkin_events.enum(source_event): | ||
print(json.dumps(event)) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
raise SystemExit(main()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BAD IDEA: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed in 5405b62 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,51 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.0", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "gherkin-official" | ||
version = "29.0.0" | ||
youtux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description = "Gherkin parser (official, by Cucumber team)" | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
authors = [ | ||
{ name = "Cucumber Ltd and Björn Rasmusson", email = "cukes@googlegroups.com" } | ||
] | ||
|
||
dependencies = [ | ||
"typing_extensions>=4", | ||
] | ||
keywords = ["gherkin", "cucumber", "bdd"] | ||
classifiers = [ | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python", | ||
"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" | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/cucumber/gherkin" | ||
Repository = "https://github.com/cucumber/gherkin.git" | ||
Download = "https://pypi.python.org/pypi/gherkin-official" | ||
Issues = "https://github.com/cucumber/gherkin/issues" | ||
Changelog = "https://github.com/cucumber/gherkin/releases" | ||
|
||
[tool.setuptools.package-data] | ||
gherkin = ["gherkin-languages.json"] | ||
|
||
[tool.setuptools.packages.find] | ||
include = ["gherkin", "gherkin.pickles", "gherkin.stream"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BETTER: Use the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in d992ac4 |
||
|
||
|
||
[tool.mypy] | ||
disallow_untyped_defs = true | ||
packages = ["gherkin"] | ||
|
||
|
||
[tool.black] | ||
# Using `(python/)?` to match both `gherkin/parser.py` and `python/gherkin/parser.py`. | ||
# This is needed to be able to run `black` as a pre-commit hook, and also to run it manually. | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BAD IDEA: Removing the scripts from the package description
gherkin/__main__.py
should be kept because that is the natural choice for the main programThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I'm even more inclined to not include the
scripts/
folder in the distribution at all.The reason is that these scripts are only used internally, as there is absolutely no API or documentation about these. Hell, I can't even figure out what the
gherkin
script does at all, since there is no documentation.I really doubt that any downstream user is using these. If anything, we are just polluting their PATH with this irrelevant
gherkin
executable.In the remote hypothesis that a downstream user was relying on this, we can always release a hotfix with the script included in the distribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the executable is needed for the purposes of the user to understand how to run main, wouldn't this be better handled with documentation?
I may have missed something, but I didn't use this executable or use it to understand how to use gherkin when I implemented it in pytest-bdd. I'm not entirely sure how useful it for including downstream from personal experience, unless I've missed a point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these scripts/executables are only for internal use, then why put them in the Python package and not put the in
bin/
directory where they were before (at least one of them).In addition, the
gherkin
script is provided in the current package version and before. Therefore, the script was part of the “API” of this package. By removing them you basically break this API in the next version. And you should be aware of that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can put them out of the
gherkin
package, so that they will automatically be out of the distributed package.yes I know, but every release is a major release it seems, so semver semantics allow this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b94911b