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

In the scaffolder, handle application and endpoint names with Python module-unfriendly characters like hyphens #40

Merged
merged 15 commits into from
Feb 16, 2024

Conversation

aholmes
Copy link
Member

@aholmes aholmes commented Feb 16, 2024

Using hyphens, spaces, etc. in the arguments for endpoint names or the application name when using bl-python-scaffold will cause invalid Python modules to generate. This PR fixes the problems by normalizing the names:

  • Module names have the invalid characters replaced with _, including space
  • URLs are lowercased but otherwise untouched

This PR adds a new argparse module to BL_Python.programming with the following functionality:

  • DisallowDuplicateValues is an argparse Action used to prevent repeated arguments from containing the same values
  • associate_disallow_duplicate_values is an argparse Action that behaves the same as DisallowDuplicateValues, but associates the argument with another argument's value
  • disallow allows argparse to error when an argument is in a list of values

Closes #38
Closes #41

@aholmes aholmes marked this pull request as ready for review February 16, 2024 02:12
@aholmes aholmes requested a review from a team as a code owner February 16, 2024 02:12
@aholmes
Copy link
Member Author

aholmes commented Feb 16, 2024

Connexion 3.0.6 contains a breaking change from 3.0.5, causing the tests to fail. I'm looking into it.

nwiltsie
nwiltsie previously approved these changes Feb 16, 2024
Copy link
Member

@nwiltsie nwiltsie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new argparse types are pretty sneaky - I like it!

@aholmes
Copy link
Member Author

aholmes commented Feb 16, 2024

@nwiltsie

The new argparse types are pretty sneaky - I like it!

I will be making a new BL_Python.programming release sometime soon, so they can be used elsewhere.

I should note I'm not particularly happy with the names. Any suggestions?

@aholmes
Copy link
Member Author

aholmes commented Feb 16, 2024

Connexion 3.0.6 contains a breaking change from 3.0.5, causing the tests to fail. I'm looking into it.

The issue is a breaking change in Starlette 0.35.0 from PR encode/starlette#2377. It turns out Starlette returning a host:port is not required by the ASGI spec, so it was decided to instead return None rather than fake values. I'll be committing a fix shortly.

…-change

Fix test failure from breaking change in Starlette
@aholmes aholmes merged commit 2194b3d into main Feb 16, 2024
6 checks passed
@aholmes aholmes deleted the aholmes-handle-hyphenated-module-names branch February 16, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants