Skip to content
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

Verbose help message on objects when possible: No flags and --help flag consistent behavior #504

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.10-slim

# Set the working directory
WORKDIR /workspace

# Install Python packages
COPY requirements.txt /workspace/
RUN pip install --no-cache-dir -r requirements.txt
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Python 3.10 with pytest",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"ms-python.python"
]
}
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"forwardPorts": [],
"postCreateCommand": ""
}
17 changes: 16 additions & 1 deletion fire/core.py
Original file line number Diff line number Diff line change
@@ -446,8 +446,23 @@ def _Fire(component, args, parsed_flag_args, context, name=None):
break

if _IsHelpShortcut(component_trace, remaining_args):
# Check to see if the class requires values in it's init function
remaining_args = []
break

# If the object has an __init__ method, that takes no arguments besides
# self, dont break yet
if not hasattr(component, '__dict__'):
break

if '__init__' not in component.__dict__:
break

parameter_count = component.__dict__['__init__'].__code__.co_argcount - 1
print(parameter_count)

# If the __init__ method does takes arguments break
if parameter_count != 0:
break

saved_args = []
used_separator = False
205 changes: 205 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.poetry]
name = "python-fire"
version = "0.1.0"
description = ""
authors = ["ESPR3SS0 <98864173+ESPR3SS0@users.noreply.github.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
termcolor = "^2.4.0"
pytest = "^8.1.1"
six = "^1.16.0"
mock = "^5.1.0"
hypothesis = "^6.100.1"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
13 changes: 12 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
.
attrs
exceptiongroup
hypothesis
iniconfig
mock
packaging
pluggy
pytest
six
sortedcontainers
termcolor
tomli