Skip to content

Prepare package for the final release#17

Merged
ajwalkiewicz merged 3 commits into
mainfrom
feature/prepare-for-release
Nov 16, 2025
Merged

Prepare package for the final release#17
ajwalkiewicz merged 3 commits into
mainfrom
feature/prepare-for-release

Conversation

@ajwalkiewicz

@ajwalkiewicz ajwalkiewicz commented Nov 16, 2025

Copy link
Copy Markdown
Owner
  • Update docsrtrings
  • Add version flag to CLI
  • Unify imports in across test suites

Summary by Sourcery

Prepare package for final release by updating documentation, standardizing test imports, bumping package metadata, adding a CLI version flag, adjusting logging defaults, and cleaning up packaging artifacts.

New Features:

  • Add --version flag to CLI for displaying the package version

Enhancements:

  • Rename project title to rname and bump version to 1.0.0-beta.2
  • Adjust CLI parser to return the parser instance and improve help output
  • Set default logging level to ERROR

Documentation:

  • Expand module‐level docstrings in init.py and config.py with usage examples and package attributes
  • Update README license link to reference LICENSE file

Tests:

  • Unify imports to use randname.core across all test suites

Chores:

  • Remove MANIFEST.in from the repository

* Update docsrtrings
* Add version flag to CLI
* Unify imports in across test suites
@sourcery-ai

sourcery-ai Bot commented Nov 16, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR prepares the package for its final release by enriching documentation and metadata, adding CLI version and help flags, unifying imports in test suites, adjusting default configuration, and bumping the project version.

Class diagram for updated CLI argument parsing and Randname core

classDiagram
    class Randname {
        +VALID_SEX_OPTIONS
        +randfirst()
        +randlast()
        +randfull()
    }
    class argparse_ArgumentParser {
        +add_argument()
        +parse_args()
        +print_help()
    }
    class parse_args {
        +args: Sequence[str] | None
        +returns: tuple[argparse.Namespace, argparse.ArgumentParser]
    }
    Randname <.. parse_args
    parse_args --> argparse_ArgumentParser : uses
    parse_args --> Randname : uses VALID_SEX_OPTIONS
Loading

Class diagram for updated config module singleton logger

classDiagram
    class set_logger {
        +level_name: str
        +returns: logging.Logger
    }
    class logger {
        <<singleton>>
        logging_level: error
    }
    set_logger --> logger : creates
Loading

File-Level Changes

Change Details Files
Expanded package documentation and metadata
  • Enriched init.py with detailed docstrings, attributes, and examples
  • Changed title to “rname” and added name attribute
  • Bumped project version in pyproject.toml to 1.0.0-beta.2
  • Updated README license link target
src/randname/__init__.py
pyproject.toml
README.md
Enhanced CLI with version and help flags
  • Adjusted parse_args signature to return (args, parser)
  • Added --version flag bound to randname.version
  • Added explicit --help/-h argument and custom prog/description
  • Updated main() to handle help printing
src/randname/__main__.py
Unified imports across test suites
  • Replaced from randname import core with import randname.core
  • Prefixed all core.rand* calls with randname.core.rand*
  • Updated teardown references to randname.core._inst.database
tests/test_randnames_es.py
tests/test_randnames_pl.py
Adjusted default logging level
  • Updated config module docstring to clarify logger singleton behavior
  • Changed default logger level from “debug” to “error”
src/randname/config.py
Corrected core example usage
  • Replaced outdated randname.full_name() example with randname.randfull()
src/randname/core.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Double-check that changing title to "rname" doesn’t break version resolution since version is loaded via version(title).
  • parse_args now returns (args, parser) instead of args alone—verify any external callers depending on the old signature remain compatible.
  • Removing MANIFEST.in may exclude non-code assets (e.g. name databases) from the package—ensure all required data files are still included in the distribution.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Double-check that changing __title__ to "rname" doesn’t break version resolution since __version__ is loaded via version(__title__).
- parse_args now returns (args, parser) instead of args alone—verify any external callers depending on the old signature remain compatible.
- Removing MANIFEST.in may exclude non-code assets (e.g. name databases) from the package—ensure all required data files are still included in the distribution.

## Individual Comments

### Comment 1
<location> `src/randname/__init__.py:52-53` </location>
<code_context>
 )

-__title__ = "randname"
+__title__ = "rname"
+__name__ = "randname"
 __version__ = version(__title__)
 __author__ = "Adam Walkiewicz"
</code_context>

<issue_to_address>
**suggestion:** Inconsistent naming between __title__ and __name__ may cause confusion.

__title__ is set to "rname" while __name__ is "randname". Please clarify the distinction or align these values to avoid ambiguity.
</issue_to_address>

### Comment 2
<location> `tests/test_randnames_es.py:19` </location>
<code_context>
     @classmethod
     def tearDownClass(cls):
-        core._inst.database = core.Randname.PATH_TO_DATABASE
+        randname.core._inst.database = randname.core.Randname.PATH_TO_DATABASE

     def setUp(self):
</code_context>

<issue_to_address>
**question (testing):** Question about test isolation and database state reset.

If tests can alter the database state, consider using a temporary database or mocking to ensure proper isolation and prevent tests from affecting each other.
</issue_to_address>

### Comment 3
<location> `tests/test_randnames_es.py:36-39` </location>
<code_context>
     def test_last_name_year(self):
         year = random.choice(self.last_names_year_range)
-        result = core.randlast(country=self.country, year=year)
+        result = randname.core.randlast(country=self.country, year=year)
         self.assertIsInstance(result, str)

</code_context>

<issue_to_address>
**suggestion (testing):** Suggestion to add assertions for output format and value constraints.

Add assertions to verify the returned name is non-empty and matches expected patterns, such as containing no digits and having a reasonable length.

```suggestion
    def test_last_name_year(self):
        year = random.choice(self.last_names_year_range)
        result = randname.core.randlast(country=self.country, year=year)
        self.assertIsInstance(result, str)
        self.assertTrue(result, "Returned last name should not be empty")
        self.assertTrue(result.isalpha(), "Last name should contain only alphabetic characters")
        self.assertGreaterEqual(len(result), 2, "Last name should be at least 2 characters long")
        self.assertLess(len(result), 50, "Last name should be less than 50 characters long")
```
</issue_to_address>

### Comment 4
<location> `tests/test_randnames_pl.py:36-39` </location>
<code_context>
     def test_last_name_year(self):
         year = random.choice(self.last_names_year_range)
-        result = core.randlast(country=self.country, year=year)
+        result = randname.core.randlast(country=self.country, year=year)
         self.assertIsInstance(result, str)

</code_context>

<issue_to_address>
**suggestion (testing):** Suggestion to add assertions for output format and value constraints.

Add assertions to verify the returned name is non-empty and conforms to expected patterns.

```suggestion
    def test_last_name_year(self):
        year = random.choice(self.last_names_year_range)
        result = randname.core.randlast(country=self.country, year=year)
        self.assertIsInstance(result, str)
        self.assertTrue(result, "Returned last name should not be empty")
        self.assertTrue(result.isalpha(), "Returned last name should contain only alphabetic characters")
        self.assertGreaterEqual(len(result), 2, "Returned last name should be at least 2 characters long")
        self.assertLessEqual(len(result), 30, "Returned last name should be at most 30 characters long")
```
</issue_to_address>

### Comment 5
<location> `tests/test_randnames_es.py:32-34` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))

<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals

Some ways to fix this:

* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.

> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>

### Comment 6
<location> `tests/test_randnames_es.py:65-67` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))

<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals

Some ways to fix this:

* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.

> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>

### Comment 7
<location> `tests/test_randnames_es.py:98-100` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))

<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals

Some ways to fix this:

* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.

> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>

### Comment 8
<location> `tests/test_randnames_es.py:102-104` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))

<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals

Some ways to fix this:

* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.

> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>

### Comment 9
<location> `tests/test_randnames_pl.py:32-34` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))

<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals

Some ways to fix this:

* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.

> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>

### Comment 10
<location> `tests/test_randnames_pl.py:65-67` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))

<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals

Some ways to fix this:

* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.

> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>

### Comment 11
<location> `tests/test_randnames_pl.py:98-100` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))

<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals

Some ways to fix this:

* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.

> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>

### Comment 12
<location> `tests/test_randnames_pl.py:102-104` </location>
<code_context>

</code_context>

<issue_to_address>
**issue (code-quality):** Avoid loops in tests. ([`no-loop-in-tests`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/no-loop-in-tests))

<details><summary>Explanation</summary>Avoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:
* loops
* conditionals

Some ways to fix this:

* Use parametrized tests to get rid of the loop.
* Move the complex logic into helpers.
* Move the complex part into pytest fixtures.

> Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / [Don't Put Logic in Tests](https://abseil.io/resources/swe-book/html/ch12.html#donapostrophet_put_logic_in_tests)
</details>
</issue_to_address>

### Comment 13
<location> `src/randname/__init__.py:53` </location>
<code_context>
"""Randname - A random name generator library.

This package provides functionality for generating random names from various
countries. It includes utilities for generating first names, last names, and
full names, with support for multiple countries and customizable options.

The package offers a simple API for generating random names that can be used in
testing, data generation, or any application requiring random name generation.

!! warning
    This package uses pseudo-random generators from Python standard library.
    This package should not be used for security purposes.
    The base package contains limited dataset of names. It is easy to create
    a collision.

Attributes:
    __title__ (str): The title of the package.
    __name__ (str): The name of the package.
    __version__ (str): The current version of the package.
    __author__ (str): The author of the package.
    __license__ (str): The license under which the package is distributed.

Examples:
    >>> import randname
    >>> randname.randfirst()
    'John'
    >>> randname.randlast()
    'Smith'
    >>> randname.randfull()
    'Jane Doe'
    >>> randname.available_countries()
    ['PL', 'US', 'ES', ...]


Modules:
    config: Configuration for logging.
    core: Core functionality for generating random names.
    database: Database handling for name data.
    error: Custom exceptions for the randname library.
"""

from importlib.metadata import version

from randname.core import (
    available_countries,
    randfirst,
    randfull,
    randlast,
    show_data,
)

__title__ = "rname"
__name__ = "randname"
__version__ = version(__title__)
__author__ = "Adam Walkiewicz"
__license__ = "MIT"

__all__ = [
    "available_countries",
    "randfirst",
    "randfull",
    "randlast",
    "show_data",
]

</code_context>

<issue_to_address>
**issue (code-quality):** Don't assign to builtin variable `\_\_name\_\_` ([`avoid-builtin-shadow`](https://docs.sourcery.ai/Reference/Default-Rules/comments/avoid-builtin-shadow/))

<br/><details><summary>Explanation</summary>Python has a number of `builtin` variables: functions and constants that
form a part of the language, such as `list`, `getattr`, and `type`
(See https://docs.python.org/3/library/functions.html).
It is valid, in the language, to re-bind such variables:

```python
list = [1, 2, 3]
```
However, this is considered poor practice.
- It will confuse other developers.
- It will confuse syntax highlighters and linters.
- It means you can no longer use that builtin for its original purpose.

How can you solve this?

Rename the variable something more specific, such as `integers`.
In a pinch, `my_list` and similar names are colloquially-recognized
placeholders.</details>
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/randname/__init__.py Outdated
Comment on lines +20 to +53
__title__ = "rname"
__name__ = "randname"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Inconsistent naming between title and name may cause confusion.

title is set to "rname" while name is "randname". Please clarify the distinction or align these values to avoid ambiguity.

Comment thread tests/test_randnames_es.py
Comment thread tests/test_randnames_es.py
Comment thread tests/test_randnames_pl.py
Comment thread tests/test_randnames_es.py
Comment thread tests/test_randnames_pl.py
Comment thread tests/test_randnames_pl.py
Comment thread tests/test_randnames_pl.py
Comment thread tests/test_randnames_pl.py
Comment thread src/randname/__init__.py Outdated
@ajwalkiewicz ajwalkiewicz merged commit 17023bc into main Nov 16, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant