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

Use strict PascalCase for class names #182

Closed
pbodnar opened this issue Jun 17, 2023 · 3 comments · Fixed by #192
Closed

Use strict PascalCase for class names #182

pbodnar opened this issue Jun 17, 2023 · 3 comments · Fixed by #192
Assignees
Milestone

Comments

@pbodnar
Copy link
Collaborator

pbodnar commented Jun 17, 2023

The historically used "lenient" usage of the PascalCase (pascal case) convention in mistletoe is quite impractical when it comes to introducing more complex names. I suggest here to use the strict variant which doesn't have this problem and leads to a more consistent code base.

E.g. change HTMLRenderer to HtmlRenderer, HTMLBlock to HtmlBlock.

For backwards compatibility, we can introduce aliases for the old names, marking them as deprecated.

@pbodnar pbodnar added this to the 1.2.0 milestone Jun 17, 2023
@pbodnar pbodnar self-assigned this Jun 17, 2023
@pbodnar
Copy link
Collaborator Author

pbodnar commented Jun 17, 2023

CC @anderskaplan.

pbodnar added a commit that referenced this issue Aug 17, 2023
This makes it more practical when compound class
names are introduced.

For backwards compatibility, we also introduce aliases
for the old names, marking them as deprecated.
pbodnar added a commit that referenced this issue Aug 17, 2023
This makes it more practical when compound class
names are introduced.

For backwards compatibility, we also introduce aliases
for the old names, marking them as deprecated.
pbodnar added a commit that referenced this issue Aug 21, 2023
This makes it more practical when compound class
names are introduced.

For backwards compatibility, we also introduce aliases
for the old names, marking them as deprecated.
@pydsigner
Copy link

Not impressed by this change. PEP-8 says:

Note: When using acronyms in CapWords, capitalize all the letters of the acronym. Thus HTTPServerError is better than HttpServerError.

Meanwhile, this is a hard-breaking change for anyone who uses mistletoe.HTMLRenderer rather than mistletoe.html_renderer.HTMLRenderer.

pbodnar added a commit that referenced this issue Aug 24, 2023
Backwards compatibility was actually broken in #182 inadvertently -
it didn't cover the case when the old `HTMLRenderer` was imported directly
from the `mistletoe` package.

Note: The `# noqa: F401` comment is for the flake8 linter, it suppresses
the `imported but unused` rule.
@pbodnar
Copy link
Collaborator Author

pbodnar commented Aug 24, 2023

@pydsigner, thanks for letting us know and sorry for the inconvenience! I have just released v1.2.1 where mistletoe.HTMLRenderer should work again.

Regarding the change to "strict PascalCase" itself, you are right that PEP-8 suggests the other way. AFAIK in C-style languages (which Python isn't, I know ;)), HtmlRenderer is the recommended way to go (see e.g. here), even if there is just one acronym in the name. But I'm not strictly against returning to the PEP-8 style, provided it will be requested by the mistletoe community...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants