Giter Site home page Giter Site logo

Comments (7)

dan-blanchard avatar dan-blanchard commented on June 12, 2024

I'm also considering whether or not we should even detect these legacy encodings by default.

from chardet.

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024

If we want to deprecate those, we should save that removal until a major version bump and communicate it well.

from chardet.

dan-blanchard avatar dan-blanchard commented on June 12, 2024

Yeah. And I don't think we should remove them entirely. We should just not check for them by default.

from chardet.

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024

So in that case, I'd like to propose a different API than what you might be thinking about for these issues.

I think a Configuration object that works like this might be good:

from chardet import config

cfg = config.Configuration().enable(
    'EUC-TW'
    ).prerefine(
    'GB2312', 'Shift_JIS', 'EUC-TW',
    )

Then this would make the selections immutable and this could be passed like so:

import chardet

chardet.detect(input_bytes, config=cfg)

from chardet.

dan-blanchard avatar dan-blanchard commented on June 12, 2024

Could you layout the advantages of that over just adding kwargs to chardet.detect?

From my perspective I could see a configuration object being really handy if you were making loads of calls to chardet.detect at various points in your code, but my intuition is that most people are just calling it once (or repeatedly in a loop).

from chardet.

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024

So, for one, I've grown to hate kwargs. Since we're supporting Python 2, it means we cannot make them keyword-only arguments which means that people will call them positionally. This makes it hard to deprecate features as we need to. Configuration objects as described above mean that we can make a method raise a DeprecationWarning, and removing it is as easy as making the method a no-op.

from chardet.

dan-blanchard avatar dan-blanchard commented on June 12, 2024

That's a really good point about deprecation. I also hate people calling keyword arguments positionally, so I think you've got the right approach there.

from chardet.

Related Issues (20)

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.