Coder Social home page Coder Social logo

bestpy's Introduction

bestpy-image

bestpy

License Linting Testing Build & Push Coverage Status GitHub stars

A module to prove your friends (or adversaries) wrong.

Ever needed to decide on what is the best thing out? That's exactly what bestpy does. We may or may not try to make the answers support your view. Here's a quick demo:

>>> best.language
"python"
>>> best.module
"bestpy"

Table of content

Installation

This is simple with pip. Just run the following in your command line or terminal:

pip install bestpy

You can also use your magic powers to get the module from the latest version of the source code using the following:

pip install git+https://github.com/gustavwilliam/bestpy.git@main

Note: you will likely need to restart your terminal before using the module

Dev installation

If you want to contribute to the bot, follow the dev install instructions instead.

Usage

We were kind and made importing it super simple and nice. Just do the following to import bestpy, once the installation is complete:

>>> from bestpy import best

Now you'll be ready to take on any of life's greatest challenges, all with the help of bestpy.

Different ways to access items

You can access items through both attribute and item access.

>>> best.module  # Attribute access
bestpy
>>> best["module"]  # Item access
bestpy

Hard coded answers

Here's how you can find out some hard coded, fundamental laws of the universe:

>>> best.year
1984
>>> best.phone
BlackBerry

Dynamic answers

There are also a few things that may sneakily check your preferences and adjust based on it, like the following. You'll get your current OS back, since you obviously have a good taste in what OS you use.

>>> best.os

Random answers

There are also a few ones that use randomness to find the truth, from a list of answers.

>>> best.name
Guido
>>> best.name
Gustav

If there's something you'd like to see added, feel free to open an issue or submit a PR. The available categories will expand over time, thanks to our awesome contributors.

Contributing

Fantastic that you want to be a part of the project! The project is actively maintained, and accepts issues and pull requests for bug fixes, new "answers" and improvements to the core functionality.

Check out CONTRIBUTING.md to get started!

Final words

Good luck proving what things are actually best. Bestpy is never wrong, so you now know everything you need to use the single source of truth. Feel free to share what you create with bestpy. I can't wait to see what you do!

May the bestpy be with you. The bestpy is strong with this one.

bestpy's People

Contributors

15696 avatar akarys42 avatar atharv-attri avatar dependabot[bot] avatar fisher60 avatar gustavwilliam avatar mushinako avatar purefunctor avatar qwerty-133 avatar supermazingcoder avatar uncomfyhalomacro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bestpy's Issues

Improve README Examples

The current README uses this example twice:

>>> best.language
"python"
>>> best.module
"bestpy"

The best Readme should provide a multitude of the best examples, to give the best help possible to new and experienced users alike.

Updating the storage of answers

@SuperMaZingCoder proposed changing the system that we use to store answers, and using JSON (@fisher60 proposed YAML) for it. The main benefit would be not keeping a huge dictionary of items in memory at all times, it seems.

Could we formalize this discussion a bit, and try to keep it in one place — this issue? Maybe we can decide on an implementation.

Accessing categories

The user will interact with Bestpy using the following syntax:

best.CATEGORY

Where CATEGORY is simply the category or topic they want to find the best thing I and best is the module they import (bestpy). The issue is how we're going to implement this in the best way possible. The answers will be in a dictionary in a separate python file (check out #3).

Goals

Here are some of the things I'd like for us to achieve with this:

  • Don't clutter up the global namespace, if possible
  • Keep it dynamic, so an update in the answers file would result in an update to the available answers straight away
  • Respect the syntax shown above. No one would like to use best.answer["CATEGORY"] or something like that

Possible solutions

We could add the values from the answers dictionary to the globals in the main file. This would presumably work, but I'm not a huge fan of cluttering up the namespace like that.

We could maybe use an excepthook to achieve this, where AttributeErrors raised with one of the available categories simply respond like usual. This seems like overkill, though, and I'm not a fan of this solution.

If you have any ideas on how we could solve this, I'd love to hear about it.

Testing

Framwork

we could use the built-in unittest to keep with the current no depends, but I really like pytest.

when the tests have been setup they should be used with #8 as well.

I would be more than happy to write the tests

setup CI for this repo

Summary

For now I just plan on using flake8 to add linting to our CI.

Implementation

I will add a fairly basic flake8 setup to the repo, we can add exclusions as we encounter rules that we do not agree with.

Setup CD

Abstract

Let’s be honest, the maintainers are lazy, let’s automate the release.

Possible triggers

  1. When a tag is pushed
  2. When a GitHub Release is created
  3. When a push to a release branch is done (could also be a merged PR)
  4. Manual Actions trigger

Implementation details

A GitHub Actions workflow would trigger, package everything, and push it to PyPi.
Two secrets will have to be added: PYPI_USERNAME and PYPI_PASSWORD.

Additional details

This can also be used to setup a nightly release, as proposed in #7.

Best way to store answers

It was discussed how to best store the answers in a way that is clean, effective and allows for flexibility. We want to allow static ans random answers, as well as ones that require code execution on every access.

Here's a possible implementation:

class CodeAnswers:
    @staticmethod
    def os():
        name = platform.system()

        # Replacing "Darwin", since it might be confusing for macOS users
        if name == "Darwin":
            name = "macOS"

        return name


answers = {
    "language": "Python",
    "package": "Bestpy",
    "os": CodeAnswers.os,
    "year": list(range(2100)),
}

The answers dict allows us to have a single source of truth. These are the basic types that I expect the values to accept:

  • Strings
  • Numeric values
  • Lists
  • Functions

Strings and numbers will simply be returned when the user runs best.CATEGORY. For lists, one of the items is randomly chosen. For functions, the function is run and the return value is treated like any other value. The example answers list given in the code above illustrates all basic types.

Category suggestions

Any category that you'd like us to add to bestpy? Feel free to comment it here, and possibly include some of the options that the package should choose from when answering.

All suggestions are appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.