fable-compiler / Fable.Python

Python bindings for Fable
https://fable.io/docs/
MIT License
136 stars 10 forks source link

Minimum python version #12

Open delneg opened 3 years ago

delneg commented 3 years ago

What version will this be working starting from ? I.e. in https://github.com/python/typeshed/blob/master/stdlib/uuid.pyi there are separate type for version 3.7 and above and others. So, it's best to determine which this lib will support right away.

dbrattli commented 3 years ago

I think we should not target anything below 3.9. Not sure how we should version this going forwards? Not sure I want to end up with multiple branches targeting different Python versions, and publish multiple NuGets for each Python version. We should try to make things simple. But what to do with e.g methods and functions added in 3.10? Should we wait until we target 3.10 as the minimum version?

delneg commented 3 years ago

IMO it's best to have something like

@available(iOS 9.0, *)
func useStackView() {
    // use UIStackView
}    

and

if #available(iOS 9.0, *) {
  // use UIStackView
} else {
  // show sad face emoji
}

to determine different versions & generate types accordingly, if possible.

hlizard commented 2 years ago

@dbrattli

I think we can use coconut: https://github.com/evhub/coconut/tree/develop https://coconut.readthedocs.io/en/latest/HELP.html#introduction

" Welcome to the tutorial for the Coconut Programming Language! Coconut is a variant of Python built for simple, elegant, Pythonic functional programming. But those are just words; what they mean in practice is that all valid Python 3 is valid Coconut but Coconut builds on top of Python a suite of simple, elegant utilities for functional programming.

Why use Coconut? Coconut is built to be useful. Coconut enhances the repertoire of Python programmers to include the tools of modern functional programming, in such a way that those tools are easy to use and immensely powerful; that is, Coconut does to functional programming what Python did to imperative programming. And Coconut code runs the same on any Python version, making the Python 2/3 split a thing of the past.

Specifically, Coconut adds to Python built-in, syntactical support for:

pattern-matching

algebraic data types

destructuring assignment

partial application

lazy lists

function composition

prettier lambdas

infix notation

pipeline-style programming

operator functions

tail call optimization

where statements

and much more! "

dbrattli commented 2 years ago

@hlizard Coconut looks like a really nice project, but I don't think it's the right abstraction for Fable. Python 2 is out of the question anyways, and solving the Python 3 problem would only be replaced with a similar Coconut version problem.

smoothdeveloper commented 1 year ago

Just to add to the discussion, right now Fable python target compiles code that doesn't seem to load in python 3.9.7, providing this error message:

TypeError: 'ABCMeta' object is not subscriptable

Stemming from

from .types import FSharpRef, Record

As far as I could search, it is from an error related to type annotation in conjunction with the @dataclass attributes that are put in the fable.core standard library for python, and it seems to trip the 3.9.7 parser.

I don't know exactly in which release it starts to work, it does work on 3.11.2, and I vaguely remember seeing "fixed in 3.10" but I can't find the PEP nor the stackoverflow answer that pointed me there.

For this reason, I'd suggest not mentioning python 3.9 or bumping this to a higher version in the readme of this repository.

As for the bindings in this repository and which version of the python library to support, that seems to be a big can of worm, python seems to be evolving fast, some of my own code written few months back starts giving me deprecation warnings after doing a minor bump of the python version.

dbrattli commented 1 year ago

Yes, agree. Removing support for Python 3.9 in Fable. Will update the readme